interface.tupleof proposal
dennis luehring
dl.soluz at gmx.net
Thu Apr 5 11:13:38 PDT 2007
BCS schrieb:
> I would really like to be able to do something like this
>
> |class Foo(T) : T
> |{
> | static assert(T : interface)
> | foreach(method; T.tupleof)
> | {
> | method.return method(method.args arg)
> | {
> | // implement based on type and args of method
> | }
> | }
> |}
>
> This would allow for some cool things like a fully template version of
> my interface-over-network code-generator. Another things would be a
> dynamic interface inheritance
>
>
> |class DnyInterface(T, V...) : T
> |{
> | private T t;
> | this(T t_){t = t_;}
> |
> | static assert(T : interface)
> | foreach(method; T.tupleof)
> | {
> | method.return method(method.args arg)
> | {
> | return t.method(arg)
> | }
> | }
> |}
>
> class Use : DnyInterface!(I) {}
>
> What exactly this would be used for I don't know, but one thought is
> that an interface returned from a dll/so could now be "inherited from"
> by a class in the loading program.
>
>
that is something that im waiting for - but it seems that no one is
interessed in such an compile-time reflectin stuff.. i would be also
nice to walk through the oop hierachie (for typed factories or something)
More information about the Digitalmars-d
mailing list