[nem-en] Virtual constructor ?

Michal Moskal michal.moskal at gmail.com
Sat Sep 30 17:59:22 CEST 2006


On 9/30/06, Alexey Borzenkov <snaury at gmail.com> wrote:
> 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.

I don't quite get it, but whatever ;-)

> 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...

SRE allows for producing any kind of junk. They sometimes check
something, but in general you cannot relay on it. They however do have
some stupid limitations here and there, like that you cannot call
GetMember on type you've just built.

-- 
   Michał


More information about the devel-en mailing list