Re: Mixin template parameters / mixin template literals

2013-04-26 Thread Idan Arye
On Friday, 26 April 2013 at 08:13:48 UTC, renoX wrote: I consider 'sort!("a > b")(array);' to be **too terse**: there is nothing here telling the reader what a and b are supposed to be. Sure there is - it's called "convention". Since all the functions in `std.algorithm` that accept delegates

Re: Mixin template parameters / mixin template literals

2013-04-26 Thread renoX
Are you really saying that 'sort!((a, b) => a > b)(array);' is too verbose?? I consider 'sort!("a > b")(array);' to be **too terse**: there is nothing here telling the reader what a and b are supposed to be. BR, renoX

Re: Mixin template parameters / mixin template literals

2013-04-24 Thread Luís.Marques
On Wednesday, 24 April 2013 at 23:42:57 UTC, Idan Arye wrote: 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 expect

Re: Mixin template parameters / mixin template literals

2013-04-24 Thread Luís.Marques
On Wednesday, 24 April 2013 at 23:04:02 UTC, ixid wrote: Is changing the language the right approach to this or would smarter IDEs possibly be a better direction? A smarter IDE always helps :-) It might not be worth changing the language for this (or it might), but changing the language to ha

Re: Mixin template parameters / mixin template literals

2013-04-24 Thread Idan Arye
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

Re: Mixin template parameters / mixin template literals

2013-04-24 Thread ixid
Consider: sort!("a > b")(array); This is almost perfect, except for "a > b" being a string instead of "real" code. If "a > b" was an actual block of code it could be syntax highlighted by the editor, directly grammar checked by compiler, etc. Is changing the language the right approach

Re: Mixin template parameters / mixin template literals

2013-04-24 Thread Luís.Marques
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. O

Re: Mixin template parameters / mixin template literals

2013-04-24 Thread Timon Gehr
On 04/24/2013 11:03 PM, Diggory wrote: On Wednesday, 24 April 2013 at 20:32:16 UTC, Timon Gehr wrote: On 04/24/2013 07:07 PM, Diggory wrote: One way this could be done is by expanding on lazy parameters. Perhaps you could specify parameters for a lazy argument, so instead of always getting a de

Re: Mixin template parameters / mixin template literals

2013-04-24 Thread Diggory
On Wednesday, 24 April 2013 at 20:32:16 UTC, Timon Gehr wrote: On 04/24/2013 07:07 PM, Diggory wrote: One way this could be done is by expanding on lazy parameters. Perhaps you could specify parameters for a lazy argument, so instead of always getting a delegate of type T delegate(), you could

Re: Mixin template parameters / mixin template literals

2013-04-24 Thread Luís.Marques
On Wednesday, 24 April 2013 at 20:50:31 UTC, bearophile wrote: Today we usually write it this way: array.sort!q{ a > b }; Thanks. (I just copied it from the docs)

Re: Mixin template parameters / mixin template literals

2013-04-24 Thread bearophile
Tove: how about? sort!(q{a > b})(array); Today we usually write it this way: array.sort!q{ a > b }; Bye, bearophile

Re: Mixin template parameters / mixin template literals

2013-04-24 Thread Timon Gehr
On 04/24/2013 07:07 PM, Diggory wrote: One way this could be done is by expanding on lazy parameters. Perhaps you could specify parameters for a lazy argument, so instead of always getting a delegate of type T delegate(), you could get one of type T delegate(U a, V b). For example, a parameter c

Re: Mixin template parameters / mixin template literals

2013-04-24 Thread Tove
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

Re: Mixin template parameters / mixin template literals

2013-04-24 Thread Diggory
One way this could be done is by expanding on lazy parameters. Perhaps you could specify parameters for a lazy argument, so instead of always getting a delegate of type T delegate(), you could get one of type T delegate(U a, V b). For example, a parameter could be: void f(lazy bool exp(int a,