     [ [ update-class ] each ]
     [ implementors [ remake-generic ] each ] bi ;
 
+: (add-mixin-instance) ( class mixin -- )
+    [ [ suffix ] change-mixin-class ]
+    [ [ f ] 2dip "instances" word-prop set-at ]
+    2bi ;
+
 : add-mixin-instance ( class mixin -- )
     #! Note: we call update-classes on the new member, not the
     #! mixin. This ensures that we only have to update the


! Definition protocol implementation ensures that removing an
! INSTANCE: declaration from a source file updates the mixin.
TUPLE: mixin-instance loc class mixin ;

M: mixin-instance equal?
    {
        { [ over mixin-instance? not ] [ f ] }
        { [ 2dup [ class>> ] bi@ = not ] [ f ] }
        { [ 2dup [ mixin>> ] bi@ = not ] [ f ] }
        [ t ]
    } cond 2nip ;

M: mixin-instance hashcode*
    [ class>> ] [ mixin>> ] bi 2array hashcode* ;

: <mixin-instance> ( class mixin -- definition )
    mixin-instance new
        swap >>mixin
        swap >>class ;

M: mixin-instance where loc>> ;

M: mixin-instance set-where (>>loc) ;

M: mixin-instance definer drop \ INSTANCE: f ;

M: mixin-instance definition drop f ;

M: mixin-instance forget*
    [ class>> ] [ mixin>> ] bi
    dup mixin-class? [ remove-mixin-instance ] [ 2drop ] if ;

! Copyright (C) 2004, 2009 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
USING: classes classes.union words kernel sequences
definitions combinators arrays assocs generic accessors ;
