New syntax for string mixins
Nick Sabalausky
a at a.a
Wed Dec 15 14:00:44 PST 2010
"Jonathan M Davis" <jmdavisProg at gmx.com> wrote in message
news:mailman.1035.1292441722.21107.digitalmars-d at puremagic.com...
> On Wednesday, December 15, 2010 11:27:47 Jacob Carlborg wrote:
>>
>> That was my idea as well, that
>>
>> @get_set("int", "bar");
>>
>> could be translated into
>>
>> mixin(get_set("int", "bar")); just like
>>
>> just like scope statements are translated into try/catch/finally.
>
> Honestly, I don't see much gain in using @ rather than mixin(). It's a
> little
> less typing, but that's it.
It does seem like a small difference, just replacing "mixin" with "@" and
removing one layer of parens. But I think that extra layer of parens, minor
as it seems, makes a big difference in the readability (and "typeability")
of mixin invocations. Those extra parens do get to be a real bother, major
visual noise at least to my eyes.
> And it precludes stuff like mixin("lhs " ~ op ~ "
> rhs") like happens all the time in overloaded operator functions.
>
I don't see why these shouldn't work:
@"int foo;";
return @("lhs " ~ op ~ " rhs");
At least with just the "@" part of the proposal. Maybe the delegate thing
might make it tricker, I dunno.
More information about the Digitalmars-d
mailing list