[Mono-list] late linking & dynamic invocation ...
Michael Meeks
michael@ximian.com
05 Jul 2002 22:15:03 +0100
On Fri, 2002-07-05 at 19:31, Miguel de Icaza wrote:
> > Ok - the problem is quite simple. In order to reasonably disambiguate
> > the 'DelegateName' you need to mangle the types into the delegate name,
> > in a signal handling system there will be a lot of these, thus:
> >
> > new DelegateName (fn) -> new DelegateLongIntShortString
> > (my_long_int_short_string_method);
>
> Ah, I would never do it that way. I would do it like this:
>
> delegate void SizeAllocation (long i, int j, string name);
>
> The delegate name is chosen to have a semantic meaning, and not match
> the method signature ;-)
Well :-) then instead of having to disambiguate on the set of signal
signature, you disambiguate on signal name - there are a lot more names
than signatures - but the point remains, you get to type the same
semantic information twice.
> win.DeleteEvent += new EventHandler (Window_Delete);
>
> Notice that the delegate signature is `EventHandler', not
> DelegateObjectEventArgs ;-)
Yes - but the 'EventHandler' signature blows - that's the whole point;
the EventHandler forces you to do your own de-marshaling, in a horribly
type un-friendly fashion; thus for eg. the above SizeAllocation you get
to do:
void mySizeAllocateMethod (Object [] args)
{
long demarshal_i = args [0];
int demarshal_j = args [1];
string demarshal_name = args [2];
... now we do the method ...
}
Contrasted with the C way which is just:
void mySizeAllocateMethod (long i, int j, 'g'char *name)
{
}
Which is (unuarguably shorter and easier) :-)
So ... I was hoping to 'fix' the prototypes to this, but seemingly
without acute pain it's not possible to make life easier - and as Ben
says it comes down to method overloading.
HTH,
Michael.
--
mmeeks@gnu.org <><, Pseudo Engineer, itinerant idiot