Am 05.09.2011, 19:51 Uhr, schrieb Sean Kelly <[email protected]>:
On Sep 3, 2011, at 9:06 PM, Andrei Alexandrescu wrote:
On 8/30/11 8:59 PM, Paul D. Anderson wrote:
Can someone clarify for me the status and/or direction of string
formatting in D?
[snip]
I agree there are major inefficiencies and composability problems
caused by a blind toString() that creates a whole new string without
any assistance. So we need to fix that.
There are suggestions to add this method to Object:
void writeTo(void delegate(const(char)[]) sink, string format = null);
Then, the suggestion goes, whether or not we deprecate toString, in the
short term it should be implemented in terms of writeTo.
There are a few questions raised by this proposal:
1. Okay, this takes care of streaming text. How about streaming in
binary format?
2. Since we have a relatively involved "output to text" routine, how
about an "input from text" routine? If writeTo is there, where is
readFrom?
Right. Which is why I've suggested in the past that we may want to use
the serialization calls for toString.
I'm highly skeptical to say the least :). I know there are languages that
serialize solely through text representations of the data, like
JavaScript, but I've yet to see this mix work in a systems language. What
serialization calls do you refer to?
- Marco