[Issue 8452] if lambda function can be template?

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Sat Jul 26 12:24:44 PDT 2014


https://issues.dlang.org/show_bug.cgi?id=8452

--- Comment #3 from Martin Nowak <code at dawg.eu> ---
(In reply to galaxylang from comment #2)
> as you can see
> 
> auto	lam3 =(x,y)=>x+y;
> lam3(1,2)
> 
> lam3 like a named variable,but it really don't save anything,just some info
> can be deduced from complier,so it's just a alias 

    file.d(1): Error: variable file.lam3 type void is inferred from initializer
(x, y) => x + y, and variables cannot be of type void

The error is confusing because templates internally have the type void.

We don't plan to support auto variables with polymorphic lambdas, because just
as you said, there is no actual variable/data involved.

> alias	lam3 =(x,y)=>x+y;
> lam3(1,2)
There is a pull request to enable the alias syntax.
https://github.com/D-Programming-Language/dmd/pull/3638

> so,i want to say,it's possible ,the key word 
> alias == auto

That I don't understand.

--


More information about the Digitalmars-d-bugs mailing list