[Mono-list] late linking & dynamic invocation ...
Miguel de Icaza
miguel@ximian.com
09 Jul 2002 02:25:58 -0400
> > As I said in an earlier message, would you care to propose a syntax for this
> > feature that will handle overloaded methods?
>
> Well - on further reflection, I don't see why (particularly) there
> should be any real problem with overloaded methods - it could be
> possible for a delegate to map to a set of methods, until Invoke time -
> surely ?
A delegate can only map to a single method, with a precise signature,
not a set of methods.
> ? you need the type information anyway to marshal the arguments
> generically, and the 'Delegate' encodes that anyhow - surely ?
Creating a delegate, like this:
delegate int Greet (string name);
Results in the compiler generating something like this:
class Greet : MulticastDelegate {
object instance;
int Invoke (string name);
...
}
It is just sintactic sugar for a common construct.
Invocations on delegates:
Greet g = get_greeting ();
g ("hey");
Become:
Greet g = get_greeting ();
g.Invoke ("hey");
Miguel