[phobos] expand for std.metastrings

Steve Schveighoffer schveiguy at yahoo.com
Tue Nov 2 14:09:29 PDT 2010


What I mean is, when just passing a string to writeln (and not using mixin to 
generate code), why do we need to invent a new syntax to do that?  We have:

writefln("take %s times.", n);

and

writeln("take ", n, " times.");

Why do we also need

writeln(expandToTuple!"take $n times."); // s/expandToTuple/someOtherName/

???

If there was a php-like way to do it like:

writeln("take $n times.");

I'd be all for that :)  But I don't see it happening.  Maybe some other type of 
quoting?

-Steve



----- Original Message ----
> From: Andrei Alexandrescu <andrei at erdani.com>
> 
> I think it would be great if we didn't have to write mixin(blah(stuff)). 
> With that... it's almost just as annoying :o).
> 
> Andrei
> 
> On  11/2/10 3:49 PM, Steve Schveighoffer wrote:
> > Is it just me, or  does
> >
> > writeln("take ", n, " times.");
> >
> > not look so  bad that we need to invent a function to do it with expansion?
> >
> >  I've used php for a while, and I love the variable expansion inside strings,  
>but
> > I don't know if it's worth defining a library function to do  it.
> >
> > -Steve
> >
> >
> >
> > ----- Original  Message ----
> >> From: Andrei Alexandrescu<andrei at erdani.com>
> >>
> >>  On 11/2/10 3:16 PM, kenji hara wrote:
> >>> And, I do not recommend  following  use of expand:
> >>> writeline(mixin(expand!"take  $n  times."));
> >>>
> >>> The probrem  is:
> >>> - expand concatenates string  by ~ operators, it is may  cost than using
> >>> appender(text, formatWrite,   writefln...)
> >>>
> >>> I will remove ddoc example from  github  code.
> >>
> >> Expand should have an option to  expand with commas and without
> >> to!string, i.e. in order to make  the  code:
> >>
> >> writeln(mixin(anotherexpand!"take $n  times."));
> >>
> >> identical  100% with the  code
> >>
> >> writeln("take ", n, "  times.");
> >>
> >> Not sure what's  the best name for   "anotherexpand".
> >>
> >> Andrei
> >>  _______________________________________________
> >> phobos  mailing  list
> >> phobos at puremagic.com
> >>  http://lists.puremagic.com/mailman/listinfo/phobos
> >>
> >
> >
> >
> >  _______________________________________________
> > phobos mailing  list
> > phobos at puremagic.com
> > http://lists.puremagic.com/mailman/listinfo/phobos
> 


      


More information about the phobos mailing list