www.digitalmars.com         C & C++   DMDScript  

D - more problems searching for overloaded functions (0.76)

reply one_mad_alien hotmail.com writes:
I though alias allowed base class members to be imported as members of the
current class !
DMD 0.76 (winXP)

I'm still of the opinion that Java has the right approach when it comes to
function searching rather than following the (imho) daft c++ model.

is the only way to get arround this to change the name of the func ?

and I think the error msg is backwards, it would seem more logical to me to
write
search.d(9): argument types (char[1],char[1]) does not match function name ()
[[then the line /file of the matched function]]
i.e. the info that is important to the programmer first.

------------ search.d ---------------------
class Base {
char[] name() { return "<name>"; }
char[] name( char[] l, char[] r ) { return l~"<name>"~r; }
}

class Derv {
alias name name;
char[] name() { return name( "a", "b" ); }
}

int main( char[][] args ) {
Base b = new Derv();
printf("rv:%.*s\n", b.name() );
return 0;
}

/*
-- without the alias at line 8
search.d(9): function name () does not match argument types (char[1],char[1])

-- with the alias at line 8
search.d(8): alias name conflicts with Derv.name at search.d(9)
*/
------------------------------------
Dec 19 2003
parent "Walter" <walter digitalmars.com> writes:
<one_mad_alien hotmail.com> wrote in message
news:bs05rh$1bv$1 digitaldaemon.com...
 I though alias allowed base class members to be imported as members of the
 current class !
 DMD 0.76 (winXP)

 I'm still of the opinion that Java has the right approach when it comes to
 function searching rather than following the (imho) daft c++ model.

 is the only way to get arround this to change the name of the func ?
At the moment, you're right. I'll need to study this.
 and I think the error msg is backwards, it would seem more logical to me
to
 write
 search.d(9): argument types (char[1],char[1]) does not match function name
()
 [[then the line /file of the matched function]]
 i.e. the info that is important to the programmer first.

 ------------ search.d ---------------------
 class Base {
 char[] name() { return "<name>"; }
 char[] name( char[] l, char[] r ) { return l~"<name>"~r; }
 }

 class Derv {
 alias name name;
 char[] name() { return name( "a", "b" ); }
 }

 int main( char[][] args ) {
 Base b = new Derv();
 printf("rv:%.*s\n", b.name() );
 return 0;
 }

 /*
 -- without the alias at line 8
 search.d(9): function name () does not match argument types
(char[1],char[1])
 -- with the alias at line 8
 search.d(8): alias name conflicts with Derv.name at search.d(9)
 */
 ------------------------------------
Jan 01 2004