Scriptlike v0.9.4 - Perl-like interpolated strings, full examples and more.

Nick Sabalausky via Digitalmars-d-announce digitalmars-d-announce at puremagic.com
Wed Sep 23 12:28:02 PDT 2015


On 09/23/2015 03:18 PM, Chad Joan wrote:
>
> This is why I argued for alternative mixin syntax in D some ... years?
> ... ago.
>
> It'd be really cool to have a writefln overload that did this:
>
> int somevar = 42;
> writefln#("This is ${somevar}");
>
> writefln#("Plus two and you get ${somevar+1}");
>
> Which would just be shorthand for
>
> int somevar = 42;
> mixin writefln!("This is ${somevar}");
>
> mixin writefln!("Plus two and you get ${somevar+2}");
>
>
> I feel like a bit of syntax sugar could go a long way ;)

Yea, the trouble with string mixins is that they're ugly enough people 
don't like to use them.

I'd argued in the past for a way to tag a CTFE-able string-returning 
function as being intended for mixing-in, so you could omit the 
"mixin(...)" part. But we only ever got it for template mixins. Allowing 
it for string mixins was too controversial. :(

I dunno, maybe even a string mixin sugar as simple as this would be a 
big help:

mixin!func(args to func here)

ie:

mixin!interp("Some string here")

But I'm guessing the ship's ling since sailed for anything like that.



More information about the Digitalmars-d-announce mailing list