math.vectors.specialization: specialized vector words are now subwords of the generic vector word. This ensures that specializations get compiled correctly in all cases

db4
Slava Pestov 2009-09-08 13:37:25 -05:00
parent 2d46cfdf9e
commit f5536bdde0
1 changed files with 8 additions and 4 deletions

View File

@ -69,12 +69,16 @@ H{
{ vtruncate { +vector+ -> +vector+ } }
}
SYMBOL: specializations
PREDICATE: vector-word < word vector-words key? ;
specializations [ vector-words keys [ V{ } clone ] H{ } map>assoc ] initialize
: specializations ( word -- assoc )
dup "specializations" word-prop
[ ] [ V{ } clone [ "specializations" set-word-prop ] keep ] ?if ;
M: vector-word subwords specializations values ;
: add-specialization ( new-word signature word -- )
specializations get at set-at ;
specializations set-at ;
: word-schema ( word -- schema ) vector-words at ;
@ -98,7 +102,7 @@ specializations [ vector-words keys [ V{ } clone ] H{ } map>assoc ] initialize
] each ;
: find-specialization ( classes word -- word/f )
specializations get at
specializations
[ first [ class<= ] 2all? ] with find
swap [ second ] when ;