proposal: a new string litteral to embed variables in a string

Timothee Cour thelastmammoth at gmail.com
Tue Nov 5 18:15:31 PST 2013


On Tue, Nov 5, 2013 at 3:19 PM, Daniel Davidson <nospam at spam.com> wrote:
>
>
> Isn't this just string interpolation which many/most languages have?
> Yes - it is a great feature. Do you have working code on github that
> others may use?
>
> Thanks
> Dan
>

This is more powerful than string interpolation, as it generates a tuple
instead of generating a string:

in my proposal,

r{var1=@a; and var2=@foo}
is replaced by
("var1=", a, "; and var2=", foo)
instead of text("var1=,a,"; and var2=",foo), as done in most languages like
you mention.

This exploits D's powerful variadic templates and is more powerful:
we can get string interpolation by simply using r{...}.text
but we can do more fancy things if needed (eg apply formatting, etc),
without requiring additional types of string litterals, as needed in scala (
http://docs.scala-lang.org/overviews/core/string-interpolation.html)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20131105/ad941a6b/attachment.html>


More information about the Digitalmars-d mailing list