Mixin template parameters / mixin template literals

Idan Arye GenericNPC at gmail.com
Wed Apr 24 16:42:56 PDT 2013


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

Token strings solve all the problems the OP mentioned, but they 
do not solve the one problem he didn't mention - closures:

     int[] array = [3, 1, 5, 2, 7];
     int x = 4;
     writeln(array.filter!(a => a < x)()); // works as expected 
and prints "[3, 1, 2]"
     writeln(array.filter!q{a < x}()); // Error: undefined 
identifier x


More information about the Digitalmars-d mailing list