2786 also mentions struct using interfaces... I take it Andrei has come around on that.
I think I'd prefer for polymorphic and static/struct interfaces to be distinct from each other. I also agree that 2785 introduces a dangerous construct when mixed with normal interfaces. Christopher Wright Wrote: > Andrei has put up a few enhancement requests in the bugzilla: > http://d.puremagic.com/issues/show_bug.cgi?id=2784 > http://d.puremagic.com/issues/show_bug.cgi?id=2785 > http://d.puremagic.com/issues/show_bug.cgi?id=2786 > > These are intended to change interfaces from being solely a tool of > polymorphism into a way of specifying type constraints. The additions > recommended can only be used at compile time (constructors, static > functions, and nested types). > > I grant that it would be quicker and clearer to write: > interface Foo > { > static void stuff(); > this (int); > } > template Template(Arg : Foo) {} > > than to write: > template Template(Arg) if (is (typeof (new Arg(0)) && > isStaticFunction!(Arg, "stuff")) {} > > However, I'm not sure whether this would be used much at all, and it > deserves some discussion. > > One detail of #2785 seems problematic: > interface Foo > { > extern void bar(int, Foo, double); > } > > meaning that a non-member function bar should exist that accepts an int, > *the implementor of Foo*, and a double. > > This is a huge and silent divergence from the standard meaning of using > the interface name; it would allow: > class C : Foo > { > static void bar(int, C, double); > } > > and disallow: > class C : Foo > { > static void bar(int, Foo, double); > } > > Thoughts? Any concerns that I have not raised? I don't do sufficient > metaprogramming to find any of this useful, I admit.
