tango list
Christopher Wright
dhasenan at gmail.com
Wed Feb 27 20:36:43 PST 2008
Bill Baxter wrote:
> You can't put a template in an interface, just a particular
> instantiation of one, as you've done there. Try it with
>
> void notify(Result)(Seq!(Result) results);
>
> I'm not sure if it's even possible to make that work. It basically says
> the interface contains a family of functions and you aren't sure which
> ones yet.
It can be made to work, but not in D, at least not right now. You
basically need a very wimpy template -- hereafter a 'generic' -- that
doesn't do any compile-time reflection and doesn't call any templates
(aside from generics). That would suffice for collections classes,
except for requiring a hash function.
In that case, the generic is equivalent to Java's generics: it just
saves you from boxing and unboxing.
I'm not sure how useful that is, though.
More information about the Digitalmars-d-learn
mailing list