The Final(ize) Challenge

Christopher Wright dhasenan at gmail.com
Mon May 18 15:54:16 PDT 2009


Andrei Alexandrescu wrote:
> I think you need to operate exclusively with string mixins in Finalize, 
> so __ident would be of marginal help there. Also, static foreach is much 
> more necessary.

That is a huge problem.

Let's say that the class you want to finalize, Target, has a method like 
this:
void foo(SomeClass){}

Let's say that SomeClass is private and in the same module as Target.

You *may* be able to do this with templates. Probably.

You *can never* do this with a string mixin.

Let's say you have another method:
void bar(SomeOtherClass!(int)){}

SomeOtherClass!(int).stringof == "SomeOtherClass". That is also 
guaranteed fail.


What you can do is:
void foo(ParameterTupleOf!(__traits(getVirtualFunctions, Target, 
"foo")[0] u) { super.foo(u); }

Here, the only string you need to mix in is for the identifier.



More information about the Digitalmars-d mailing list