www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Passing a Delegate as Parameter

reply Joshua Cearley <jtech ezoob.com> writes:
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

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"
Feb 22 2005
parent Russ Lewis <spamhole-2001-07-16 deming-os.org> writes:
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

 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"
Feb 22 2005