Annoyances with traits
F i L
witte2008 at gmail.com
Thu Mar 29 10:07:27 PDT 2012
I'd like to add to what I suggested earlier. Conversion between
types is a common and expected behavior. Because std.conv is
small, and the new UFCS is here, I think object.d could benefit.
Hear what I had in mind:
+ Move std.conv functionality to object.d
+ Move Object.toString() from the base class, to free space.
+ Make toString() simply wrap to!string() and depreciate it.
+ Replace parse!() with a more intelligent to!()/string
+ emplace!() would be handy to always have around :)
+ idk what to do with text!() :/
Now we can convert types as a language feature, and toString()
still works, but universally on any type that defines opCall().
Also, like I said, toString() might just wrap to!string() and be
marked as depreciated (since we already have .stringof).
auto name = "Jacque Fresco";
auto age = 96;
writeln("Hi, I'm ", name, ".");
writeln("I'm ", age.text(), " years old");
writeln("This shit's got to go!"); // ;)
writeln("How old are you?");
auto line = readln();
auto theirAge = line.to!int();
More information about the Digitalmars-d
mailing list