Re: delegate from lambda expression

2012-09-10 Thread Jacob Carlborg
On 2012-09-10 01:20, timotheecour wrote: I'd like to achieve the following: import std.stdio,std.range,std.algorithm,std.array; void main(){ auto dg=a=a*2; auto a=iota(0,10); writeln(a.map!dg.array); } but this doesn't compile: Error: variable [...]dg type void is inferred

delegate from lambda expression

2012-09-09 Thread timotheecour
I'd like to achieve the following: import std.stdio,std.range,std.algorithm,std.array; void main(){ auto dg=a=a*2; auto a=iota(0,10); writeln(a.map!dg.array); } but this doesn't compile: Error: variable [...]dg type void is inferred from initializer delegate (__T26 a) {

Re: delegate from lambda expression

2012-09-09 Thread bearophile
timotheecour: I'd like to achieve the following: import std.stdio,std.range,std.algorithm,std.array; void main(){ auto dg=a=a*2; auto a=iota(0,10); writeln(a.map!dg.array); } but this doesn't compile: Error: variable [...]dg type void is inferred from initializer delegate

Re: delegate from lambda expression

2012-09-09 Thread bearophile
Because in D there is no global inferencer, On the other hand it's not impossible to invent a syntax for templated lambdas, etc :-) Bye, bearophile

Re: delegate from lambda expression

2012-09-09 Thread Timon Gehr
On 09/10/2012 01:55 AM, bearophile wrote: Your code doesn't look good, Yes it does.

Re: delegate from lambda expression

2012-09-09 Thread Timon Gehr
On 09/10/2012 01:20 AM, timotheecour wrote: I'd like to achieve the following: import std.stdio,std.range,std.algorithm,std.array; void main(){ auto dg=a=a*2; auto a=iota(0,10); writeln(a.map!dg.array); } but this doesn't compile: Error: variable [...]dg type void is

Re: delegate from lambda expression

2012-09-09 Thread bearophile
timotheecour: What was wrong with it and what would you suggest to improve it? Nothing serious, I just suggest to give a bit more air to your code, adding a space around operators, after commas, etc. Otherwise your code risk looking like Timon's code ;-) I have also compiled the code with