diff --git a/core/namespaces/namespaces-tests.factor b/core/namespaces/namespaces-tests.factor index 616ddef7fc..a7b1e50880 100644 --- a/core/namespaces/namespaces-tests.factor +++ b/core/namespaces/namespaces-tests.factor @@ -3,7 +3,7 @@ IN: namespaces.tests H{ } clone "test-namespace" set -: test-namespace ( -- ) +: test-namespace ( -- ? ) H{ } clone dup [ namespace = ] bind ; [ t ] [ test-namespace ] unit-test @@ -14,6 +14,9 @@ H{ } clone "test-namespace" set unit-test SYMBOL: test-initialize + +f test-initialize set-global + test-initialize [ 1 ] initialize test-initialize [ 2 ] initialize diff --git a/core/namespaces/namespaces.factor b/core/namespaces/namespaces.factor index 24095fd382..623e2ddcda 100644 --- a/core/namespaces/namespaces.factor +++ b/core/namespaces/namespaces.factor @@ -29,15 +29,7 @@ PRIVATE> : dec ( variable -- ) -1 swap +@ ; inline : bind ( ns quot -- ) swap >n call ndrop ; inline : counter ( variable -- n ) global [ 0 or 1+ dup ] change-at ; - -: make-assoc ( quot exemplar -- hash ) - 20 swap new-assoc [ >n call ndrop ] keep ; inline - -: with-scope ( quot -- ) - H{ } clone >n call ndrop ; inline - -: with-variable ( value key quot -- ) - [ associate >n ] dip call ndrop ; inline - -: initialize ( variable quot -- ) - [ global ] [ [ unless* ] curry ] bi* change-at ; +: make-assoc ( quot exemplar -- hash ) 20 swap new-assoc [ swap bind ] keep ; inline +: with-scope ( quot -- ) H{ } clone swap bind ; inline +: with-variable ( value key quot -- ) [ associate ] dip bind ; inline +: initialize ( variable quot -- ) [ global ] dip [ unless* ] curry change-at ; inline \ No newline at end of file