Mixin template parameters / mixin template literals

"Luís "Luís
Wed Apr 24 14:14:11 PDT 2013


On Wednesday, 24 April 2013 at 20:32:16 UTC, Timon Gehr wrote:
>> Then when you call that:
>> f(a < b)
> This is a little dangerous as it looks like an ordinary 
> expression but has to somehow affect symbol scoping.

That's true, and that was one reason I suggested some kind of 
template mixin literal. On the other hand, that's just an extreme 
version of what happens with lazy, where at the call site you 
can't tell that the argument side effects are not produced 
immediately. Without experience with features like this it's hard 
to tell if their usefulness pays for their cost, but it seems to 
me that something like this could make for very powerful macros.

On Wednesday, 24 April 2013 at 17:38:34 UTC, Tove wrote:
> how about?
> sort!(q{a > b})(array);
>
> http://dlang.org/lex.html#TokenString

I was not aware of the token strings, is that new? Boy, I really 
should spend more time around here. That's an excellent 
suggestion, although I think these "mixin parameters" we are 
discussing are more like mixin template parameters than mixin 
string parameters.


More information about the Digitalmars-d mailing list