All right, all right! Interim decision regarding qualified Object methods
Jonathan M Davis
jmdavisProg at gmx.com
Fri Jul 13 02:10:23 PDT 2012
On Friday, July 13, 2012 11:02:30 F i L wrote:
> I always wondered why toString() wasn't just to!string() in the
> first place, short of UFCS not being implemented for all types.
to!string(obj) uses typeof(obj).toString for user-defined types. Even if
to!string is arguably the better way to convert to a string, it still needs an
implementation, and for user-defined types, that's toString. It could be argued
though that we should have just used opCast(T)() if(is(T == string)) {} rather
than toString. However, given the push to have a version of toString that
writes to an output range or a scoped delegate rather than creating a new
string, the opCast wouldn't have fit as well ultimately.
- Jonathan M Davis
More information about the Digitalmars-d
mailing list