[nem-en] Virtual constructor ?
Alexey Borzenkov
snaury at gmail.com
Sat Sep 30 16:22:49 CEST 2006
On 9/30/06, Andrei Varanovich <dotnetby at gmail.com> wrote:
> AFAIK, Nemerle doesn't support virtual constructors, right?
It's not about Nemerle doesn't support it, in .NET it just doesn't
really make sense. Remembering 'type of' from Delphi, where I first
seen the concept of virtual constructors (suppose sometype2 inherits
sometype1 and sometype1 has virtual constructor, then if we assign
sometype2 to variable of type 'type of sometype1' and call this
virtual constructor then sometype2 constructor will be called, while
for non-virtual constructors it will always be sometype1 constructor),
in .NET we only have Type type, and when we execute
Activator.CreateInstace it always peeks the actual type constructor,
so we can just speculate that in .NET all constructors are virtual.
However when constructor is marked as virtual assemblies doesn't
verify nor load. Strange that Reflection.Emit allows producing such IL
in the first place...
More information about the devel-en
mailing list