digitalmars.D.learn - tango list
- quest (5/5) Feb 27 2008 hi,
- Christopher Wright (4/13) Feb 27 2008 // Use a list of any type of element
- quest (2/17) Feb 27 2008
- Robert Fraser (8/23) Feb 27 2008 Why not?
- Bill Baxter (15/40) Feb 27 2008 You can't put a template in an interface, just a particular
- Christopher Wright (9/17) Feb 27 2008 It can be made to work, but not in D, at least not right now. You
- Steven Schveighoffer (8/21) Feb 28 2008 you can, but not in the way you are saying:
hi, i would like to hand over some LinkSeq list to some funktions. what would be function header?? void testfunc(???? lists, int bolony) { .... } seems like i can't use LinkSeq for the ????.
Feb 27 2008
quest wrote:hi, i would like to hand over some LinkSeq list to some funktions. what would be function header?? void testfunc(???? lists, int bolony) { .... } seems like i can't use LinkSeq for the ????.// Use a list of any type of element void testfunc(T)(ListSeq!(T) list, int bologna) {} Unfortunately, you won't be able to put that in an interface.
Feb 27 2008
thank you, that did the trick! Christopher Wright Wrote:quest wrote:hi, i would like to hand over some LinkSeq list to some funktions. what would be function header?? void testfunc(???? lists, int bolony) { .... } seems like i can't use LinkSeq for the ????.// Use a list of any type of element void testfunc(T)(ListSeq!(T) list, int bologna) {} Unfortunately, you won't be able to put that in an interface.
Feb 27 2008
Christopher Wright wrote:quest wrote:Why not? interface ResultCollector { void notify(Result r); void notify(Seq!(Result) results); Seq!(Result) getResults(); }hi, i would like to hand over some LinkSeq list to some funktions. what would be function header?? void testfunc(???? lists, int bolony) { .... } seems like i can't use LinkSeq for the ????.// Use a list of any type of element void testfunc(T)(ListSeq!(T) list, int bologna) {} Unfortunately, you won't be able to put that in an interface.
Feb 27 2008
Robert Fraser wrote:Christopher Wright 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. 'Course you *can* make a templated interface: interface ResultCollector(Result) { void notify(Result r); void notify(Seq!(Result) results); Seq!(Result) getResults(); } --bbquest wrote:Why not? interface ResultCollector { void notify(Result r); void notify(Seq!(Result) results); Seq!(Result) getResults(); }hi, i would like to hand over some LinkSeq list to some funktions. what would be function header?? void testfunc(???? lists, int bolony) { .... } seems like i can't use LinkSeq for the ????.// Use a list of any type of element void testfunc(T)(ListSeq!(T) list, int bologna) {} Unfortunately, you won't be able to put that in an interface.
Feb 27 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.
Feb 27 2008
"Christopher Wright" wrotequest wrote:you can, but not in the way you are saying: interface myinterface(T) { void testfunc(ListSeq!(T) list, int balogna); } In fact, all the tango containers implement interfaces like this. -Stevehi, i would like to hand over some LinkSeq list to some funktions. what would be function header?? void testfunc(???? lists, int bolony) { .... } seems like i can't use LinkSeq for the ????.// Use a list of any type of element void testfunc(T)(ListSeq!(T) list, int bologna) {} Unfortunately, you won't be able to put that in an interface.
Feb 28 2008