Preserving const? -- A potential solution
Christopher Wright
dhasenan at gmail.com
Sun Mar 8 06:28:34 PDT 2009
Daniel Keep wrote:
>
> Tim M wrote:
>> Firstly option 2 was just crazy and I don't know why you said that.
>
> Because it's how .NET does it. Granted, .NET doesn't really have
> templates; just deferred type erasure. Still, it's basically the same idea.
This is a much easier feature to support, assuming you have sufficient
reflection. You'd output some type constraints for the metadata on the
generic element. On instantiation of a generic method, the runtime would
check the given type against those constraints. Local variables of the
generic type would be stored in an array on the heap, perhaps, or you
could extend the stack as necessary. Methods and properties would all be
accessed via reflection.
Dog slow, and it only works out as syntactic sugar. It isn't worthwhile.
More information about the Digitalmars-d
mailing list