interface.tupleof proposal
BCS
ao at pathlink.com
Tue Apr 3 16:23:11 PDT 2007
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.
More information about the Digitalmars-d
mailing list