[Mono-devel-list] Dynamically changing classes?

Thomas Sondergaard thomas at thomassondergaard.com
Wed Sep 24 14:12:15 EDT 2003

Can a .net class be changed at runtime? Can you add/remove methods and
fields at runtime?

If one were to compile a dynamically typed language like Ruby or Python to
IL and the classes were to be directly represented by .net classes and not
.net objects this would be necessary.

I have been using the emit API but this just adds a new assembly either to
memory or a file, so I don't see how I can use it to dynamically change
existing types.

In CIL you can call a virtual function. This, as far as I understand, is the
limit to late binding as implemented in .net (without reflection). In ruby
and Python the concept of sending messages to an object is more dynamic and
has nothing to do with types. Using Type.InvokeMember you can mimic this
behaviour on .net but could it is relatively slow. Why not add a new
instruction to the CLR that is simply called e.g. 'send_msg'  that accepts a
methodName string and a list of parameters? This would be essential for
dynamically typed languages wouldn't it.

Disclaimer: I don't really know much about this I'm just wondering what kind
of platform support that is necessary if you want dynamically typed
languages to execute more or less directly on the CLR, meaning that classes
are represented by .net classes and not .net objects.



More information about the Mono-devel-list mailing list