toString ugliness
Jerry
jlquinn at optonline.net
Sat Dec 6 08:21:11 PST 2008
toString() doesn't work inside a class member function.
import std.string;
class A {
void f() {
string s = toString(5);
}
}
This errors with junk.d(19): function object.Object.toString () does not match parameter types (int)
This is a nuisance and a wart (though not a bug per-se).
If the language really can't handle distinguishing this.toString() from toString(int), then std.string.toString really should have a different name.
It can be solved somewhat by documenting clearly that to!(string)(int)
be used instead, which seems silly to me. I'm irritated by the 3 extra chars required to type a to!(type) template.
.toString() works around the problem, but why should it be needed? This is unfortunate.
Does this bother anyone else? If not, I'll return to my lurking cave :-)
More information about the Digitalmars-d
mailing list