php strings demo

Nick Sabalausky a at a.a
Sun Nov 21 05:48:38 PST 2010


"Kagamin" <spam at here.lot> wrote in message 
news:ic9fjp$1nok$1 at digitalmars.com...
> See attachment. It's just a thought. Anyone want this in the language?
> ---
> string sval="ab128#d";
> int ival=274;
> static assert("asdf \{sval} astt35 \{ival} zzf \{uuu} g,d" ==
> "asdf ab128#d astt35 274 zzf uuu g,d"); //(uuu not found)
> ---
>

Yes.

Ruby has that to:
var = 42
puts "The value of var plus 7 is #{var + 7}"

Actually, that's pretty common in scripting languages. Although, I'd be 
happy at least with a a good string templating lib. Something like:

auto str1 = "The value of $name$ is $val$".render( ["name":"myVar", 
"val":"17"] );

auto str2 = "Alternate delimiters are ::what::".render( ["what":"useful"], 
"::" );

That'd be more general anyway. 




More information about the Digitalmars-d mailing list