Clean up namespaces a bit

db4
Slava Pestov 2009-02-20 20:51:51 -06:00
parent be40bd33ee
commit 591472f7a9
2 changed files with 8 additions and 13 deletions

View File

@ -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

View File

@ -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