sylvan wrote:
In ASM a delegate is any memory length of n bits that is addressable
In C a delegate is a size_t, which is an int or long or long long depending on the processor size.
In C++ a delegate is not significantly changed from C, but it is type-checked at compile time.
In C# a delegate is a C++ function pointer which is (and I
quote)
Delegates are roughly similar to function pointers in C++; however, delegates are type-safe and secure.
C# encapsulates the delegate as follows:
System.Delegate {
System.Reflection.MethodBase _methodBase;
int _methodPtr;
int _methodPtrAux;
object _methodTarget
}
When invoked statically the _methodPtr is the *void which fully describes the function. When invoked via reflection, the _methodBase describes a reflection-safe method of invokation. The methodTarget is required for instance functions which are passed as the
last parameter to an instance call (OOP functions arn't actually OOP when they are compiled).
A C# delegate invokation in CIL involves pushing the arguments of the delegate onto the stack, followed by asking the System.Delegate to invoke, which optionally pushes the target to the stack (it doesn't if the delegate is static) and then CIL-calls the methodptr,
which is *void.
Thread Closed
This thread is kinda stale and has been closed but if you'd like to continue the conversation, please create a new thread in our Forums,
or Contact Us and let us know.