The Final(ize) Challenge
davidl
davidl at nospam.org
Tue May 19 20:30:16 PDT 2009
在 Tue, 19 May 2009 05:29:09 +0800,Jarrett Billingsley
<jarrett.billingsley at gmail.com> 写道:
> On Mon, May 18, 2009 at 5:12 PM, Jarrett Billingsley
> <jarrett.billingsley at gmail.com> wrote:
>> ...
>
> Aaand for contrast, if we had __ident and static foreach:
>
> final class Finalize(T) : T
> {
> this(T...)(T args) if(is(typeof(new T(args)))) { super(args); }
>
> static foreach(member; __traits(allMembers, T))
> static if(__traits(isVirtualFunction, __traits(getMember, T,
> member)) && !__traits(isFinalFunction, __traits(getMember, T,
> member)))
> override ReturnType!(__traits(getMember, T, member))
> __ident(member)(ParameterTypeTuple!(__traits(getMember, T, member)
> args)
> { return super.__ident(member)(args); }
> }
Err this sort of __ident is implemented by my patch against allMembers.
It's arranged as:
[ "membername", membersymbol, "member2name", membersymbol]
that is
__traits(allMembers, ClassSym)[1](3,4) would call the second member of
ClassSym with args (3,4)
--
使用 Opera 革命性的电子邮件客户程序: http://www.opera.com/mail/
More information about the Digitalmars-d
mailing list