On 2010-12-15 23:00, Nick Sabalausky wrote:
"Jonathan M Davis"<jmdavisp...@gmx.com>  wrote in message
news:mailman.1035.1292441722.21107.digitalmar...@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 completely agree.

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.

My idea was actually to get rid of the strings where the code to be mixed in is defined and to have a better syntax where it's used.

The delegates are just a way of passing a block of code around. If you just use it in place then maybe one could do like this:

@(int foo;);
return @(lhs@(op)rhs);

--
/Jacob Carlborg

Reply via email to