]> gitweb.factorcode.org Git - factor.git/commitdiff
functors: use with-words instead of more fragile qualified-vocabs pop*.
authorJohn Benediktsson <mrjbq7@gmail.com>
Wed, 16 Dec 2020 01:23:30 +0000 (17:23 -0800)
committerJohn Benediktsson <mrjbq7@gmail.com>
Wed, 16 Dec 2020 01:23:30 +0000 (17:23 -0800)
basis/functors/functors.factor

index 79aff0d16efab044542a76d2865c94f5672784a7..f69998fdfceef6d870b0f4f3237a6b42b80ea398 100644 (file)
@@ -149,20 +149,22 @@ DEFER: ;FUNCTOR> delimiter
         [ nip scan-object 2array ]
     } cond ;
 
-: parse-bindings ( end -- words assoc )
+: parse-bindings ( end -- words )
+    '[ _ parse-binding dup ]
+    [ first2 [ make-local ] dip 2array ]
+    produce nip ;
+
+: with-bindings ( ..a end quot: ( ..a words -- ..b ) -- ..b )
     '[
-        building get use-words
-        [ _ parse-binding dup ]
-        [ first2 [ make-local ] dip 2array ]
-        produce nip
-    ] H{ } make ;
+        building get [ _ parse-bindings @ ] with-words
+    ] H{ } make drop ; inline
 
 : parse-functor-body ( -- form )
     functor-words [
-        "WHERE" parse-bindings drop
-        [ swap <def> suffix ] { } assoc>map concat
-        \ ;FUNCTOR> parse-until [ ] append-as
-        qualified-vocabs pop* ! unuse the bindings
+        "WHERE" [
+            [ swap <def> suffix ] { } assoc>map concat
+            \ ;FUNCTOR> parse-until [ ] append-as
+        ] with-bindings
     ] with-lambda-scope ;
 
 : (<FUNCTOR:) ( -- word def effect )