]> gitweb.factorcode.org Git - factor.git/commitdiff
namespaces: Way better implementation of with-variable-on.
authorDoug Coleman <doug.coleman@gmail.com>
Wed, 31 May 2017 00:53:22 +0000 (19:53 -0500)
committerDoug Coleman <doug.coleman@gmail.com>
Wed, 31 May 2017 00:58:19 +0000 (19:58 -0500)
core/namespaces/namespaces-tests.factor
core/namespaces/namespaces.factor

index 48f3b1cf1256b221b133efdc9526cb1f330b6b39..7ef7502fc54e2c2a47c6327af4bd249a7e9305d3 100644 (file)
@@ -38,3 +38,7 @@ SYMBOL: toggle-test
 
 { t } [ [ test-initialize get-global ] { at* set-at } inlined? ] unit-test
 { t } [ [ test-initialize set-global ] { at* set-at } inlined? ] unit-test
+
+SYMBOL: bool-test
+{ t } [ bool-test [ bool-test get ] with-variable-on ] unit-test
+{ f } [ bool-test [ bool-test get ] with-variable-off ] unit-test
index 2ab8c9a2e751df10c1bde8439117eae2d84acd0a..dd6765af2a96fe21c52891bcd118b603c20c2389 100644 (file)
@@ -67,6 +67,6 @@ PRIVATE>
 : with-variables ( ns quot -- ) swap >n call ndrop ; inline
 : with-scope ( quot -- ) 5 <hashtable> swap with-variables ; inline
 : with-variable ( value key quot -- ) [ associate ] dip with-variables ; inline
-: with-variable-on ( key quot -- ) [ t swap associate ] dip with-variables ; inline
-: with-variable-off ( key quot -- ) [ f swap associate ] dip with-variables ; inline
+: with-variable-on ( key quot -- ) [ t ] 2dip with-variable ; inline
+: with-variable-off ( key quot -- ) [ f ] 2dip with-variable ; inline
 : with-global ( quot -- ) [ global ] dip with-variables ; inline