Thread overview
interface.tupleof proposal
Apr 03, 2007
BCS
Apr 05, 2007
dennis luehring
Apr 05, 2007
Dan
April 03, 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.


April 05, 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)
April 05, 2007
dennis luehring Wrote:
> 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)

For now, I'd say don't use classes.  Use AA's, or arrays of unions?

Walter and friends *are* interested in compile-time reflection.  Look up their talks about reflecting the AST.