New syntax for string mixins

Pelle Månsson pelle.mansson at gmail.com
Thu Dec 16 02:18:57 PST 2010


On 12/15/2010 11:00 PM, Nick Sabalausky wrote:
> "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.
>

I agree with this. Actually, just removing the parenthesis would be a 
huge gain for me.

>> 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.
>

This could work, but I don't think anyone is suggesting completely 
replacing the mixin. I think @ could be a function/template thing, and 
have strings in a more explicit mixin"";

Then again, inconsistency sucks.


More information about the Digitalmars-d mailing list