Emulation macros and pattern matching on D
Dennis Ritchie via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Fri Jun 5 13:03:58 PDT 2015
On Friday, 5 June 2015 at 19:08:19 UTC, Steven Schveighoffer
wrote:
> It's just so I didn't have to escape the quotes :D
>
> Otherwise it looks like this:
>
> return "writefln(\"mode " ~ mode ~ ": %s\", " ~ value ~ ");"
But such an option is possible to do work? : D
return `writefln(q"["mode]" ` ~ mode ~ `q"[: %s"]", ` ~ value ~
`);`;
> I think we can probably do a compile-time substitution
> processor like rust (and other languages, including php and
> ruby) which just uses the variable name inside a string with
> some escape around it. `~var~` is not very succinct, I like
> $var better.
It would be very good, because many have long been trying to
implement this functionality handmade :)
http://www.prowiki.org/wiki4d/wiki.cgi?DanielKeep/shfmt
More information about the Digitalmars-d-learn
mailing list