473,386 Members | 1,817 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

C# 14.5.5.1: what means "all methods declared in a base type of T are removed"?

Method invocation will consist of the following steps:

1. Member lookup (14.3) - evaluate method group set (Base.f() and
Derived.f()) .Standart say:
"The compile-time processing of a method invocation of the form M(A), where
M is a method group and A is
an optional argument-list, consists of the following steps:
 The set of candidate methods for the method invocation is constructed.
Starting with the set of methods
associated with M, which were found by a previous member lookup (14.3),
...."

2. Remove non-applicable methods and methods of base classes. In this
example both Base.f() and Derived.f() are applicable. Standart say:
"... the set is reduced to those
methods that are applicable with respect to the argument list A. The set
reduction consists of applying
the following rules to each method T.N in the set, where T is the type in
which the method N is declared:
If N is not applicable with respect to A (14.4.2.1), then N is removed from
the set.
If N is applicable with respect to A (14.4.2.1), then all methods declared
in a base type of T are removed
from the set."

But what mean words "then all methods declared in a base type of T are
removed from the set"? If all methods must be removed than test() method in
example must invoke Derived.f(), but MSVC# invoke Base.f(). Why? Any
suggestions.

class Source
{
static public implicit operator Target ( Source source )
{ return new Target(); }
}

class Target
{}

class Base
{
public void f ( Source source )
{}
}

class Derived : Base
{
public void f ( Target target ) // this function is applicable
(user-defined implicit conversion used)
{}

public void test()
{
Source source = new Source();
f ( source ); // invoke Base.f() - why?
}
}

Alex.
Nov 16 '05 #1
4 1482
Alex Sedow wrote:
Method invocation will consist of the following steps:

1. Member lookup (14.3) - evaluate method group set (Base.f() and
Derived.f()) .Standart say:
"The compile-time processing of a method invocation of the form M(A), where
M is a method group and A is
an optional argument-list, consists of the following steps:
 The set of candidate methods for the method invocation is constructed.
Starting with the set of methods
associated with M, which were found by a previous member lookup (14.3),
..."

2. Remove non-applicable methods and methods of base classes. In this
example both Base.f() and Derived.f() are applicable. Standart say:
"... the set is reduced to those
methods that are applicable with respect to the argument list A. The set
reduction consists of applying
the following rules to each method T.N in the set, where T is the type in
which the method N is declared:
If N is not applicable with respect to A (14.4.2.1), then N is removed from
the set.
If N is applicable with respect to A (14.4.2.1), then all methods declared
in a base type of T are removed
from the set."

But what mean words "then all methods declared in a base type of T are
removed from the set"? If all methods must be removed than test() method in
example must invoke Derived.f(), but MSVC# invoke Base.f(). Why? Any
suggestions.

class Source
{
static public implicit operator Target ( Source source )
{ return new Target(); }
}

class Target
{}

class Base
{
public void f ( Source source )
{}
}

class Derived : Base
{
public void f ( Target target ) // this function is applicable
(user-defined implicit conversion used)
{}

public void test()
{
Source source = new Source();
f ( source ); // invoke Base.f() - why?
}
}


In my test, Derived.test() invokes Derived.f().

--
mikeb
Nov 16 '05 #2
Alex Sedow wrote:
Method invocation will consist of the following steps:

1. Member lookup (14.3) - evaluate method group set (Base.f() and
Derived.f()) .Standart say:
"The compile-time processing of a method invocation of the form M(A), where
M is a method group and A is
an optional argument-list, consists of the following steps:
 The set of candidate methods for the method invocation is constructed.
Starting with the set of methods
associated with M, which were found by a previous member lookup (14.3),
..."

2. Remove non-applicable methods and methods of base classes. In this
example both Base.f() and Derived.f() are applicable. Standart say:
"... the set is reduced to those
methods that are applicable with respect to the argument list A. The set
reduction consists of applying
the following rules to each method T.N in the set, where T is the type in
which the method N is declared:
If N is not applicable with respect to A (14.4.2.1), then N is removed from
the set.
If N is applicable with respect to A (14.4.2.1), then all methods declared
in a base type of T are removed
from the set."

But what mean words "then all methods declared in a base type of T are
removed from the set"? If all methods must be removed than test() method in
example must invoke Derived.f(), but MSVC# invoke Base.f(). Why? Any
suggestions.

class Source
{
static public implicit operator Target ( Source source )
{ return new Target(); }
}

class Target
{}

class Base
{
public void f ( Source source )
{}
}

class Derived : Base
{
public void f ( Target target ) // this function is applicable
(user-defined implicit conversion used)
{}
That's not true. The convertion is applied when you
call the method. So you still have 2 distinct methods:

f(Source)
f(Target)

public void test()
{
Source source = new Source();
f ( source ); // invoke Base.f() - why?


because f(Source) is still visible and it is the best match.

Bye
Rob
Nov 16 '05 #3
"mikeb" <ma************@nospam.mailnull.com> wrote in message
news:#a**************@TK2MSFTNGP11.phx.gbl...

In my test, Derived.test() invokes Derived.f().

--
mikeb


You right. Sorry. I not there have seen.

Alex.
Nov 16 '05 #4
"Robert Jordan" <ro*****@gmx.net> wrote in message
news:ch*************@news.t-online.com...
That's not true. The convertion is applied when you
call the method. So you still have 2 distinct methods:

f(Source)
f(Target)

public void test()
{
Source source = new Source();
f ( source ); // invoke Base.f() - why?


because f(Source) is still visible and it is the best match.

Bye
Rob


I not there have seen.
f ( source ) invoke Derived.f().

Alex.
Nov 16 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: ReignMan | last post by:
I'm running JDK 1.4.0_01, Xalan2.5.1 and Tomcat 4.1.27. XSL transformations work, yet when running in debug mode (Eclipse IDE), I get the following: 990S2html.xsl:3:80: Element type...
12
by: cppaddict | last post by:
Hi, I know that it is illegal in C++ to have a static pure virtual method, but it seems something like this would be useful when the following 2 conditions hold: 1. You know that every one...
5
by: Duck Dodgers | last post by:
Here is my situation class base { }; class child1 { int data; }; class child2 {
1
by: Derek | last post by:
I am writing a web application for job seekers, and am adding a section that allows administrators to upload jobs to the system via xml. I have used an xml schema to validate the xml they upload....
175
by: Ken Brady | last post by:
I'm on a team building some class libraries to be used by many other projects. Some members of our team insist that "All public methods should be virtual" just in case "anything needs to be...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.