From f5536bdde0df53b22f40fd201359864a2d460a1d Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Tue, 8 Sep 2009 13:37:25 -0500 Subject: [PATCH] math.vectors.specialization: specialized vector words are now subwords of the generic vector word. This ensures that specializations get compiled correctly in all cases --- .../vectors/specialization/specialization.factor | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/basis/math/vectors/specialization/specialization.factor b/basis/math/vectors/specialization/specialization.factor index c9db3e02b3..a31a209a19 100644 --- a/basis/math/vectors/specialization/specialization.factor +++ b/basis/math/vectors/specialization/specialization.factor @@ -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 ;