www.digitalmars.com         C & C++   DMDScript  

D - bug: overloaded function with same name as derived function

reply mike.wynn l8night.co.uk writes:
Two things

can we have a new news group d.bugs for just compiler bug reporting and 
checking if issues are known bugs or required features.

It appears, that if you overload a function that you have not overrided
the compiler can not find it.
in delphi there is the overload attribute, D has override (which I belive is
optional) but no overload or explicit way to import from superclass as the
compiler when overloading.

you will see in the following code example.

import c.stdio;

class B
{
bit func() { return true; }
// but works without problem
bit spam() { return false; }
}

class D : /* public */ B  
// the public did not improve things, strange that was allowed!
{
int func( char[] name ) { return name.length; }
//  but this solves the problem :(
// comment this out and this does not compile
bit func() { return super.func(); }
}

int main( char[][] args )
{
D d = new D();

if ( d.func() )
{
return d.func( args[0] );
}
if ( d.spam() )
{
return args.length;
}
return 0;
}
Jun 03 2002
parent "Matthew Wilson" <mwilson nextgengaming.com> writes:
Agree on the separate bug group.

<mike.wynn l8night.co.uk> wrote in message
news:adgn0d$2c15$1 digitaldaemon.com...
 Two things

 can we have a new news group d.bugs for just compiler bug reporting and
 checking if issues are known bugs or required features.

 It appears, that if you overload a function that you have not overrided
 the compiler can not find it.
 in delphi there is the overload attribute, D has override (which I belive
is
 optional) but no overload or explicit way to import from superclass as the
 compiler when overloading.

 you will see in the following code example.

 import c.stdio;

 class B
 {
 bit func() { return true; }
 // but works without problem
 bit spam() { return false; }
 }

 class D : /* public */ B
 // the public did not improve things, strange that was allowed!
 {
 int func( char[] name ) { return name.length; }
 //  but this solves the problem :(
 // comment this out and this does not compile
 bit func() { return super.func(); }
 }

 int main( char[][] args )
 {
 D d = new D();

 if ( d.func() )
 {
 return d.func( args[0] );
 }
 if ( d.spam() )
 {
 return args.length;
 }
 return 0;
 }
Jun 05 2002