Clean up namespaces a bit
parent
be40bd33ee
commit
591472f7a9
|
@ -3,7 +3,7 @@ IN: namespaces.tests
|
||||||
|
|
||||||
H{ } clone "test-namespace" set
|
H{ } clone "test-namespace" set
|
||||||
|
|
||||||
: test-namespace ( -- )
|
: test-namespace ( -- ? )
|
||||||
H{ } clone dup [ namespace = ] bind ;
|
H{ } clone dup [ namespace = ] bind ;
|
||||||
|
|
||||||
[ t ] [ test-namespace ] unit-test
|
[ t ] [ test-namespace ] unit-test
|
||||||
|
@ -14,6 +14,9 @@ H{ } clone "test-namespace" set
|
||||||
unit-test
|
unit-test
|
||||||
|
|
||||||
SYMBOL: test-initialize
|
SYMBOL: test-initialize
|
||||||
|
|
||||||
|
f test-initialize set-global
|
||||||
|
|
||||||
test-initialize [ 1 ] initialize
|
test-initialize [ 1 ] initialize
|
||||||
test-initialize [ 2 ] initialize
|
test-initialize [ 2 ] initialize
|
||||||
|
|
||||||
|
|
|
@ -29,15 +29,7 @@ PRIVATE>
|
||||||
: dec ( variable -- ) -1 swap +@ ; inline
|
: dec ( variable -- ) -1 swap +@ ; inline
|
||||||
: bind ( ns quot -- ) swap >n call ndrop ; inline
|
: bind ( ns quot -- ) swap >n call ndrop ; inline
|
||||||
: counter ( variable -- n ) global [ 0 or 1+ dup ] change-at ;
|
: counter ( variable -- n ) global [ 0 or 1+ dup ] change-at ;
|
||||||
|
: make-assoc ( quot exemplar -- hash ) 20 swap new-assoc [ swap bind ] keep ; inline
|
||||||
: make-assoc ( quot exemplar -- hash )
|
: with-scope ( quot -- ) H{ } clone swap bind ; inline
|
||||||
20 swap new-assoc [ >n call ndrop ] keep ; inline
|
: with-variable ( value key quot -- ) [ associate ] dip bind ; inline
|
||||||
|
: initialize ( variable quot -- ) [ global ] dip [ unless* ] curry change-at ; 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 ;
|
|
Loading…
Reference in New Issue