February 22, 2005 Passing a Delegate as Parameter | ||||
---|---|---|---|---|
| ||||
I am trying to make a Signal/Slot system (the kind that Qt uses) for a library I am creating (currently named Crystal Widgets Toolkit) which strives to be something like the .NET framework for C# and the JDK for D. Currently, I've run in to one problem. How would I pass a delegate as a function parameter? I tried aliasing but that only gives me awkward errors. I don't have the source code at the moment and I'm about to go to bed so I can't give the specific error. Any help would be gladly appreciated. -Joshua Cearley BlackCrystal Software "Making dreams reality" |
February 22, 2005 Re: Passing a Delegate as Parameter | ||||
---|---|---|---|---|
| ||||
Posted in reply to Joshua Cearley | void foo(int delegate(char,float,double) arg) { ... }
Note the difference between the way that you declare a delegate type, which is:
<retval> delegate(<args>)
and the way that you declare a delegate literal, which is:
delegate <retval>(<args>) { <code> }
Joshua Cearley wrote:
> I am trying to make a Signal/Slot system (the kind that Qt uses) for a
> library I am creating (currently named Crystal Widgets Toolkit) which
> strives to be something like the .NET framework for C# and the JDK for D.
> Currently, I've run in to one problem.
>
> How would I pass a delegate as a function parameter? I tried aliasing but
> that only gives me awkward errors. I don't have the source code at the
> moment and I'm about to go to bed so I can't give the specific error.
>
> Any help would be gladly appreciated.
>
> -Joshua Cearley
> BlackCrystal Software
> "Making dreams reality"
|
Copyright © 1999-2021 by the D Language Foundation