Efficient outputting of to-string conversions

Jonathan M Davis jmdavisProg at gmx.com
Tue Feb 8 08:02:36 PST 2011


On Tuesday 08 February 2011 07:55:23 spir wrote:
> On 02/07/2011 11:38 PM, Tomek Sowiński wrote:
> > Jonathan M Davis napisał:
> >> On Monday 07 February 2011 13:10:09 Tomek Sowiński wrote:
> >>> Looks like std.conv.to always allocates behind the scenes. It's a shame
> >>> as the returned string is immediately processed and discarded in my
> >>> XML writer. Are there plans to include a custom output variant, e.g.
> >>> to!string(7, outputRange)?
> >> 
> >> http://prowiki.org/wiki4d/wiki.cgi?LanguageDevel/DIPs/DIP9
> > 
> > I know about Steven's proposal but it applies only to user types not
> > primitives. Either way std.conv.to would need a buffered output range as
> > integers are written from the right. Any chance for an abstraction
> > analogous to buffered input ranges discussed recently?
> 
> I haven't read a solution like the proposal for writeTo would not apply to
> primitives. Is it really so? (If only for language consistency, I would
> prefere this big shift to apply to all types.)

Umm. _How_ would it apply to primitives. Does _toString_ apply to primitives? 
No. toString and writeTo apply to user-defined types that they're defined on. That 
doesn't mean that we can't or shouldn't find a buffered solution for dealing with 
primitives and I/O similar to writeTo, but primitives can't have writeTo defined 
on them any more than they can have toString defined on them.

- Jonathan M Davis


More information about the Digitalmars-d mailing list