toString not working... (a bug in D?)

Ary Manzana ary at esperanto.org.ar
Tue Jan 16 04:43:28 PST 2007


Marcin Kuszczak escribió:
> Orgoton wrote:
> 
>> Ok, now I did
>>
>> import std.string;
>> ushort number=1092;
>> char[] text="Some text " ~ toString(number);
>>
>> and the compiler claimed that the number of arguments of
>> Object.object.toString() did not match... So, I did
>>
>> char[] text="Some text " ~ std.string.toString(number);
>>
>> and it worked fine. Is this a compiler bug? I did not import object (as it
>> is implicitly done). Or have I some weird compiler configuration?
> 
> Probably you did:
> char[] text="Some text " ~ toString(number);
> 
> in class method, so compiler thought you want to refer to Object's
> toString() method.
> 
> You should escape current scope of class with '.' (dot).
> class Test {
>         void method(int number) {
>                 char[] text="Some text " ~ .toString(number);
>         }
> }
> 
> Above code should work.
> 

That's not very intuitive :-(

Can't this be fixed? toString methods should be easy to work since they 
are widely used.



More information about the Digitalmars-d mailing list