Scriptlike v0.9.4 - Perl-like interpolated strings, full examples and more.
Meta via Digitalmars-d-announce
digitalmars-d-announce at puremagic.com
Wed Sep 23 17:42:21 PDT 2015
On Wednesday, 23 September 2015 at 19:28:03 UTC, Nick Sabalausky
wrote:
> 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.
What about even just removing the syntax distinction between
string mixins and template mixins?
mixin "int i = 0";
mixin declareI!();
While we're at it, how about optional parens for templates as
well as functions?
More information about the Digitalmars-d-announce
mailing list