overload/ride
Ant
duitoolkit at yahoo.ca
Sat May 19 20:44:20 PDT 2007
Chris Nicholson-Sauls wrote:
> Ant wrote:
>> I'm trying to use tango and I found Cout doesn't take int.
[...]
>
> I believe that's by design. If you are wanting more flexible output
> than flat strings can provide, I recommend trying tango.io.Stdout:Stdout
> instead.
thank you, I got that tip for the IRC also.
>
>> Am I doing something wrong? is this a D limitation?
>> where is the super.opCall(char[]) hiding?
>
> Its hiding in the parent class, and this is a limitation. The problem
> is that the lookup rules will not automatically look to the parent class
> if the symbol has matches in the current class. Oy. The fix is this:
>
>
> alias Console.Output.opCall opCall; // <- the fix
>
>
[...]
> The problem here is a more interesting one, and it has to do with your
> overloads. They should be returning 'MOutput's rather than
> 'Console.Output's, other wise the chained calls to opCall() will happen
> in Console.Output's namespace... isn't OOP fun?
>
[...]
> -- Chris Nicholson-Sauls
You're right, so the real fix is:
MOutput opCall(char[] str)
{
super.opCall(str);
return this;
}
MOutput opCall(int i)
{
// do something here
return this;
}
of course, this has no real use, just helped me better understand D.
thanks.
Ant
More information about the Digitalmars-d-learn
mailing list