On 2011-09-22 00:50, Andrei Alexandrescu wrote:
On 9/21/11 5:29 PM, bearophile wrote:
Walter Bright:

D
(a,b) { return a + b; }

In D to define a true lambda you need types too:
auto f = (int a,int b){ return a + b; };

No.

Andrei

void foo (int delegate (int, int) a){}

void main ()
{
        foo((a, b) { return a +b;});
}

Results in:

main.d(48): Error: undefined identifier a
main.d(48): Error: undefined identifier b
main.d(48): Error: function main.foo (int delegate(int, int) a) is not callable using argument types (_error_ delegate(_error_, _error_)) main.d(48): Error: cannot implicitly convert expression (__dgliteral1) of type _error_ delegate(_error_, _error_) to int delegate(int, int) Failed: /Users/jacob/.dvm/bin/dvm-current-dc -v -o- '/Users/jacob/development/d/main.d' -I'/Users/jacob/development/d' >/Users/jacob/development/d/main.d.deps

--
/Jacob Carlborg

Reply via email to