www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Trying to pass lambda to function gives strange error

reply Incognito <Incognito regmail.com> writes:
function foo (double x, double y, bool function(bar) callback)
is not callable using argument types
(double, double, bool function() pure nothrow  nogc  safe 
function(bar w) pure nothrow  nogc  safe)

I've tried with passing a delegate.

I am calling it like

foo(0,0, (bar b) => { return true; });

It seems the only difference is all those attributes?!?! Surely I 
don't have to specify all that junk when creating a lambda?
Jun 11 2016
parent Incognito <Incognito regmail.com> writes:
On Saturday, 11 June 2016 at 22:58:00 UTC, Incognito wrote:
 function foo (double x, double y, bool function(bar) callback)
 is not callable using argument types
 (double, double, bool function() pure nothrow  nogc  safe 
 function(bar w) pure nothrow  nogc  safe)

 I've tried with passing a delegate.

 I am calling it like

 foo(0,0, (bar b) => { return true; });

 It seems the only difference is all those attributes?!?! Surely 
 I don't have to specify all that junk when creating a lambda?
Nevermind. The => is the problem. D should definitely give a better warning message than that!
Jun 11 2016