digitalmars.D.learn - tango list
- quest <quest questx.com> Feb 27 2008
- Christopher Wright <dhasenan gmail.com> Feb 27 2008
- quest <quest <quest questx.com>> Feb 27 2008
- Robert Fraser <fraserofthenight gmail.com> Feb 27 2008
- Bill Baxter <dnewsgroup billbaxter.com> Feb 27 2008
- Christopher Wright <dhasenan gmail.com> Feb 27 2008
- "Steven Schveighoffer" <schveiguy yahoo.com> Feb 28 2008
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: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.
Why not? interface ResultCollector { void notify(Result r); void notify(Seq!(Result) results); Seq!(Result) getResults(); }
Feb 27 2008
Robert Fraser wrote: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.
Why not? interface ResultCollector { void notify(Result r); void notify(Seq!(Result) results); Seq!(Result) getResults(); }
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(); } --bb
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: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.
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. -Steve
Feb 28 2008









quest <quest <quest questx.com>> 