Emulation macros and pattern matching on D

Steven Schveighoffer via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Fri Jun 5 12:08:19 PDT 2015


On 6/5/15 11:52 AM, Dennis Ritchie wrote:
> On Friday, 5 June 2015 at 14:31:19 UTC, anonymous wrote:
>> You messed up the quotes. You might be mistaking backticks for
>> something special, but they're basically just quotes.
>
> Yes, the sample program really made me think that gravis (backticks) -
> is something special...

It's just so I didn't have to escape the quotes :D

Otherwise it looks like this:

return "writefln(\"mode " ~ mode ~ ": %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.

-Steve


More information about the Digitalmars-d-learn mailing list