In this example, the generic word dispatches on p1 instead of t3:
TUPLE: t1 s1 ;
TUPLE: t2 < t1 ;
TUPLE: t3 < t2 ;
PREDICATE: p1 < t1 s1>> ;
GENERIC: foo ( class -- print )
M: t1 foo drop "t1" ;
M: t2 foo drop "t2" ;
M: t3 foo drop "t3" ;
M: p1 foo drop "p1" ;
t3 new t >>s1 foo
! --- Data stack:
! "p1"
\ foo order
! --- Data stack:
! { t1 t2 t3 p1 }
! which probably should have been { t1 p1 t2 t3 } according to precedence
rule and metaclass ranking rule combined.
! with a little scruffier structure
TUPLE: t1 s1 ;
TUPLE: t2 < t1 ;
TUPLE: t3 < t2 ;
PREDICATE: p1 < t1 s1>> ;
PREDICATE: p2 < t2 s1>> ;
PREDICATE: p3 < p2 s1>> ;
t1 class-usages sort-classes
! --- Data stack:
! { t1 t2 t3 p2 p3 p1 }
! what i expected: { t1 p1 t2 p2 p3 t3 }
! with mixins
TUPLE: t1 s1 ;
TUPLE: t2 < t1 ;
TUPLE: t3 < t2 ;
MIXIN: m1
INSTANCE: t2 m1
MIXIN: m2
INSTANCE: t3 m2
t1 class-usages sort-classes
! --- Data stack:
! { t1 m2 m1 t2 t3 }
! i am not sure what was the expected behavior of this, i just wanted to
test further. though i think there is a problem with this one, too.
i am not experienced in OOP, but IMHO dispatch order on mixins should be
handled specially, probably mixin should be placed in the order dynamically,
i.e mixins placed in dispatch order every time according to which instance
is of the mixin is making the dispatch predicate on the mixin true. I
haven't tested for combinations with other metaclasses. but i can do some if
needed.
BTW, I wrote some words for tuple constructors aiming to handle shadowed
slots better -with heavy help from folks in channel- :
http://paste.factorcode.org/annotation.txt?id=1083 you might want to take a
look at them. boa constructor normally tries to get values from stack for
shadowed slots, too. shadowed-boa word first places the initial value of
each shadowed slot at corresponding places in stack, (i didn't choose to
just place f values because factor still checks for the declared slot type
even when the slot is shadowed, so placing f doesn't work) then it calls boa
as usual, and i wrote a mark-shadowed word that places a +shadow+ symbol as
a value to those slots, mark shadowed uses low-level slot operators so it
passes slot type checking. marking them makes it easy for user to see what
is going on in the tuple if at inspector or listener. I am not sure if this
would be something generally useful though, i hope it is. thanks.
------------------------------------------------------------------------------
WhatsUp Gold - Download Free Network Management Software
The most intuitive, comprehensive, and cost-effective network
management toolset available today. Delivers lowest initial
acquisition cost and overall TCO of any competing solution.
http://p.sf.net/sfu/whatsupgold-sd
_______________________________________________
Factor-talk mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/factor-talk