That's great - thanks Dan Daniel Ehrenberg wrote: > Very soon, things will be changed to real tuple inheritance. In > certain cases, with the delegate system, your approach won't work (for > example if some generic word has a default method for objects) so you > may need to define a mixin for indexes. Otherwise, this is a very > nice, well-factored solution. > > Actually, there's another way you could go about this: define a single > index class, and make a slot for which type of index it is (which you > can readably store as a symbol). Then, define three predicate classes > which subclass index and check if they have the right symbol. here's > now that'd look: > > TUPLE: index fname type ; > C: <index> index > > PREDICATE: index pso-index index-type pso-index = ; > PREDICATE: index ops-index index-type ops-index = ; > PREDICATE: index pos-index index-type pos-index = ; > > : <pso-index> pso-index <index> ; > : <ops-index> ops-index <index> ; > : <pos-index> pos-index <index> ; > > When tuple inheritance is added, the code will be able to look > something like this: > > TUPLE: index fname ; > > TUPLE: pso-index < index ; > C: <pso-index> pso-index > > TUPLE: ops-index < index ; > C: <ops-index> ops-index ; > > TUPLE: pos-index < index ; > C: <pos-index> pos-index > > Daniel Ehrenberg > > On Jan 7, 2008 8:38 AM, Phil Dawes <[EMAIL PROTECTED]> wrote: >> Hi Factor List, >> >> I've got a base class tuple that I want to inherit 3 subclasses from. >> The subclasses don't have state of their own, but are merely used for >> polymorphic method dispatch. I'm using delegates as follows: >> >> <PRIVATE >> TUPLE: index fname ; >> C: <index> index >> PRIVATE> >> >> : construct-index-delegate ( fname subclass -- obj ) >> >r <index> r> construct-empty tuck set-delegate ; >> >> TUPLE: pso-index ; >> TUPLE: osp-index ; >> TUPLE: pos-index ; >> >> : <pso-index> pso-index construct-index-delegate ; >> : <osp-index> osp-index construct-index-delegate ; >> : <pos-index> pos-index construct-index-delegate ; >> >> Is this the best approach? >> >> Cheers, >> >> Phil >> >> >> >> ------------------------------------------------------------------------- >> This SF.net email is sponsored by: Microsoft >> Defy all challenges. Microsoft(R) Visual Studio 2005. >> http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ >> _______________________________________________ >> Factor-talk mailing list >> [email protected] >> https://lists.sourceforge.net/lists/listinfo/factor-talk >> > > ------------------------------------------------------------------------- > This SF.net email is sponsored by: Microsoft > Defy all challenges. Microsoft(R) Visual Studio 2005. > http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ > _______________________________________________ > Factor-talk mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/factor-talk >
------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2005. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ _______________________________________________ Factor-talk mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/factor-talk
