On Wed, May 22, 2019 at 10:33:52PM +0000, Alex via Digitalmars-d-learn wrote:
> In gtkD one can use a lambda directly:
> 
>     X.addOnButtonPress((GdkEventButton* e, Widget w) ...
> 
> but if I try move the lambda in to a variable so I can use it with
> multiple handlers, I get an error:
> 
>     // x is a function and does not work
>     auto x = (GdkEventButton* e, Widget w) ...
>     X.addOnButtonPress(x);
> 
> etc...
> 
> It's because the second case treats x as a function while the first it
> is a delegate and addOnButtonPress requires a delegate...
[...]

You could try explicitly declaring it as a delegate:

        void delegate(GdkEventButton*, Widget) x = (e, w) { ... };
        X.addOnButtonPress(x);


T

-- 
I am Ohm of Borg. Resistance is voltage over current.

Reply via email to