[Mono-list] late linking & dynamic invocation ...

Miguel de Icaza miguel@ximian.com
04 Jul 2002 16:21:34 -0400

Hello Michael,

   I am having a bit of trouble understanding what the problem is that
you are trying to solve in the discussion about delegates.  

   For any "callback" function that you might want to call from your
code, you will need to have a delegate definition, this is just part of
the contract of the signature, so implementors can create methods
conforming to this definition.

   Methods with a signature are not a problem: every method will have a
signature, there is no way around that, so I do not consider that to be
a problem:

> 	a) declare your method - with signature:
> 		void myAllocateHandler (Widget     w,
> 				        Allocation a,
> 					Object     closure)
> 		{ ... }
> 	b) declare a Delegate type somewhere [ ok - so this can be
> 	   done only once in a header somewhere ]
> 		delegate FooWidgetAllocationObject  
> 			(Widget w,Allocation a,Object o);


> 	c) re-type the method signature [ in some mangled form ] in the
> 	   name of the delegate on connection:
> 		object.connect (new FooWidgetAllocationObject 
> 			(myAllocateHandler));

You do not retype the signature, instead you use the delegate name:

	object += new FooWidgetAllocation (myAllocationHandler)

So there are two sides of the problem:

	* The "definition" side, which consists of a delegate

	* The "user" side, which consists of doing the object +=
	  new DelegateName (Function).

I do not see what the complexity is.

> 	So it seems we need a generic way of creating delegates - I was hoping
> to hear the language provided some way to do this - there should be, it
> seems trivial to get right.