: test-emit ( cpu rep quot -- node )
[
[ new \ cpu ] 2dip '[
- test-compiler-env [ _ test-node @ ] bind
+ test-compiler-env [ _ test-node @ ] with-variables
] with-variable
] make-classes ; inline
: test-emit-literal ( cpu lit rep quot -- node )
[
[ new \ cpu ] 3dip '[
- test-compiler-env [ _ _ test-node-literal @ ] bind
+ test-compiler-env [ _ _ test-node-literal @ ] with-variables
] with-variable
] make-classes ; inline
: test-emit-nonliteral-rep ( cpu quot -- node )
[
[ new \ cpu ] dip '[
- test-compiler-env [ test-node-nonliteral-rep @ ] bind
+ test-compiler-env [ test-node-nonliteral-rep @ ] with-variables
] with-variable
] make-classes ; inline
[ 3 ]
[
- global [ 3 \ foo set ] bind
+ global [ 3 \ foo set ] with-variables
\ foo [ global >n get namespaces.private:ndrop ] compile-call
] unit-test
[ 3 ]
[
- global [ 3 \ foo set ] bind
+ global [ 3 \ foo set ] with-variables
\ foo [ global [ get ] swap blech call ] compile-call
] unit-test
[ 3 ]
[
- global [ 3 \ foo set ] bind
+ global [ 3 \ foo set ] with-variables
\ foo [ global [ get ] swap >n call namespaces.private:ndrop ] compile-call
] unit-test
[ 3 ]
[
- global [ 3 \ foo set ] bind
- \ foo [ global [ get ] bind ] compile-call
+ global [ 3 \ foo set ] with-variables
+ \ foo [ global [ get ] with-variables ] compile-call
] unit-test
[ 12 13 ] [
} [
nl print get keys natural-sort stack.
] assoc-each
- ] bind ;
+ ] with-variables ;
: optimizer-report. ( word -- )
make-report report. ;
_ [
dup +bottom+ eq?
[ drop null-info ] [ value-info ] if
- ] bind
+ ] with-variables
] map
] 2map ;
] if ;
M: mock-io-backend link-info
- global [ link-info ] bind ;
+ global [ link-info ] with-variables ;
[ ] [ 0 counter boa dummy-monitor-created set ] unit-test
[ ] [ 0 counter boa dummy-monitor-disposed set ] unit-test
io.sockets.private io.streams.duplex kernel libc locals math
math.parser sequences system threads unix unix.ffi
vocabs ;
-EXCLUDE: namespaces => bind ;
EXCLUDE: io => read write ;
EXCLUDE: io.sockets => accept ;
IN: io.sockets.unix
?rewrite-closures ;
: parse-multi-def ( locals -- multi-def )
- [ ")" [ make-local ] map-tokens ] bind <multi-def> ;
+ [ ")" [ make-local ] map-tokens ] with-variables <multi-def> ;
: parse-def ( name/paren locals -- def )
- over "(" = [ nip parse-multi-def ] [ [ make-local ] bind <def> ] if ;
+ over "(" = [ nip parse-multi-def ] [ [ make-local ] with-variables <def> ] if ;
M: lambda-parser parse-quotation ( -- quotation )
H{ } clone (parse-lambda) ;
{ 1 2 } [
1 2 <foo> T{ foo f ?a ?b } match [
?a ?b
- ] bind
+ ] with-variables
] unit-test
{ 1 2 } [
1 2 <foo> \ ?a \ ?b <foo> match [
?a ?b
- ] bind
+ ] with-variables
] unit-test
{ H{ { ?a ?a } } } [
[
first2
[ [ dupd match ] curry ] dip
- [ bind ] curry rot
+ [ with-variables ] curry rot
[ ?if ] 2curry append
] reduce ;
: match-replace ( object pattern1 pattern2 -- result )
[ match [ "Pattern does not match" throw ] unless* ] dip swap
- [ replace-patterns ] bind ;
+ [ replace-patterns ] with-variables ;
: ?1-tail ( seq -- tail/f )
dup length zero? not [ rest ] [ drop f ] if ;
gensym [
<mirror> [
"foo" "name" set
- ] bind
+ ] with-variables
] [ name>> ] bi
] unit-test
-[ gensym <mirror> [ "compiled" off ] bind ] must-fail
+[ gensym <mirror> [ "compiled" off ] with-variables ] must-fail
TUPLE: declared-mirror-test
{ a integer initial: 0 } ;
3 declared-mirror-test boa <mirror> [
5 "a" set
"a" get
- ] bind
+ ] with-variables
] unit-test
-[ 3 declared-mirror-test boa <mirror> [ t "a" set ] bind ] must-fail
+[ 3 declared-mirror-test boa <mirror> [ t "a" set ] with-variables ] must-fail
TUPLE: color
{ red integer }
parser set \r
swap (transform) \r
main set \r
- ] bind ;\r
+ ] with-variables ;\r
\r
M: ebnf (transform) ( ast -- parser )\r
rules>> [ (transform) ] map last ;\r
"-output-image=" prepend ,
"-pic=0" ,
] { } make
- ] bind ;
+ ] with-variables ;
: parse-vocab-manifest-file ( path -- vocab-manifest )
utf8 file-lines [ "empty vocab manifest!" throw ] [
"hello-ui" deploy-config [
bootstrap-profile staging-image-name file-name
"." split second
- ] bind
+ ] with-variables
] unit-test
[ ] [ "maze" shake-and-bake 1200000 small-enough? ] unit-test
[ "Contents/Resources" copy-resources ]
[ "Contents/Frameworks" copy-libraries ] 2bi
bundle-name show-in-finder
- ] bind
+ ] with-variables
] with-directory ;
: deploy-app-bundle? ( vocab -- ? )
- deploy-config [ deploy-console? get not deploy-ui? get or ] bind ;
+ deploy-config [ deploy-console? get not deploy-ui? get or ] with-variables ;
M: macosx deploy* ( vocab -- )
! pass off to M: unix deploy* if we're building a console app
"Saving final image" show
save-image-and-exit
] deploy-error-handler
- ] bind ;
+ ] with-variables ;
: do-deploy ( -- )
"output-image" get
: pool-values ( assoc -- assoc' ) [ pool-array ] assoc-map ;
H{ } clone \ pool [
- global [
+ [
! Only keeps those methods that we actually call
sent-messages get super-sent-messages get assoc-union
objc-methods [ assoc-intersect pool-values ] change
! We need this for strip-stack-traces to work fully
{ message-senders super-message-senders }
[ get values compile ] each
- ] bind
+ ] with-global
] with-variable
\ make-prepare-send reset-memoized
bundle-name "" [ copy-resources ] [ copy-libraries ] 3bi
bundle-name normalize-path "Binary deployed to " "." surround print
bundle-name webbrowser:open-file
- ] bind
+ ] with-variables
] with-directory ;
[ nip "" [ copy-resources ] [ copy-libraries ] 3bi ]
[ nip open-in-explorer ]
} 2cleave
- ] bind
+ ] with-variables
] with-directory ;
deploy-settings-theme
namespace <mapping> >>model
- ] bind ;
+ ] with-variables ;
: find-deploy-gadget ( gadget -- deploy-gadget )
[ deploy-gadget? ] find-parent ;
: parse-fault ( xml -- fault-code fault-string )
first-child-tag first-child-tag first-child-tag
- xml>item [ "faultCode" get "faultString" get ] bind ;
+ xml>item [ "faultCode" get "faultString" get ] with-variables ;
: receive-rpc ( xml -- rpc )
dup main>> dup "methodCall" =
sort-keys values <enum> ;
: undo-xml ( xml -- quot )
- [undo-xml] '[ H{ } clone [ _ bind ] keep >enum ] ;
+ [undo-xml] '[ H{ } clone [ _ with-variables ] keep >enum ] ;
\ interpolate-xml 1 [ undo-xml ] define-pop-inverse
text-now? get [ parse-text f ] [
get-char [ make-tag t ] [ f f ] if
] if text-now? set
- ] bind ;
+ ] with-variables ;
<PRIVATE
make-assoc
with-scope
with-variable
- bind
+ with-variables
} ;
ARTICLE: "namespaces-change" "Changing variable values"
{ $values { "quot" quotation } { "exemplar" assoc } { "hash" "a new assoc" } }
{ $description "Calls the quotation in a new namespace of the same type as " { $snippet "exemplar" } ", and outputs this namespace when the quotation returns. Useful for quickly building assocs." } ;
-HELP: bind
+HELP: with-variables
{ $values { "ns" assoc } { "quot" quotation } }
{ $description "Calls the quotation in the dynamic scope of " { $snippet "ns" } ". When variables are looked up by the quotation, " { $snippet "ns" } " is checked first, and setting variables in the quotation stores them in " { $snippet "ns" } "." } ;
H{ } clone "test-namespace" set
: test-namespace ( -- ? )
- H{ } clone dup [ namespace = ] bind ;
+ H{ } clone dup [ namespace = ] with-variables ;
[ t ] [ test-namespace ] unit-test
10 "some-global" set
[ f ]
-[ H{ } clone [ f "some-global" set "some-global" get ] bind ]
+[ H{ } clone [ f "some-global" set "some-global" get ] with-variables ]
unit-test
SYMBOL: test-initialize
: +@ ( n variable -- ) [ 0 or + ] change ; inline
: inc ( variable -- ) 1 swap +@ ; inline
: dec ( variable -- ) -1 swap +@ ; inline
-: bind ( ns quot -- ) swap >n call ndrop ; inline
+: with-variables ( ns quot -- ) swap >n call ndrop ; inline
: counter ( variable -- n ) [ 0 or 1 + dup ] change-global ;
-: make-assoc ( quot exemplar -- hash ) 20 swap new-assoc [ swap bind ] keep ; inline
-: with-scope ( quot -- ) 5 <hashtable> swap bind ; inline
-: with-variable ( value key quot -- ) [ associate ] dip bind ; inline
-: with-global ( quot -- ) global swap bind ; inline
+: make-assoc ( quot exemplar -- hash ) 20 swap new-assoc [ swap with-variables ] keep ; inline
+: with-scope ( quot -- ) 5 <hashtable> swap with-variables ; inline
+: with-variable ( value key quot -- ) [ associate ] dip with-variables ; inline
+: with-new-scope ( quot -- ) 5 <hashtable> swap with-variables ; inline
+: with-global ( quot -- ) [ global ] dip with-variables ; inline
: initialize ( variable quot -- ) [ unless* ] curry change-global ; inline
USING: namespaces parser ;
IN: vocabs.loader.test.a
-<< global [ "count-me" inc ] bind >>
+<< global [ "count-me" inc ] with-variables >>
: v-l-t-a-hello ( -- a ) 4 ;
USING: namespaces ;
IN: vocabs.loader.test.b
-<< global [ "count-me" inc ] bind >>
+<< global [ "count-me" inc ] with-variables >>
: fred bob ;
\ No newline at end of file
IN: vocabs.loader.test.g
USING: vocabs.loader.test.f namespaces ;
-global [ "vocabs.loader.test.g" inc ] bind
+[ "vocabs.loader.test.g" inc ] with-global
: cocreate ( quot -- co )
coroutine new
dup current-coro associate
- [ swapd , , \ bind ,
+ [ swapd , , \ with-variables ,
"Coroutine has terminated illegally." , \ throw ,
] [ ] make
[ >>resumecc ] [ >>originalcc ] bi ;
FCGI_UNKNOWN_ROLE ;
:: debug-print ( print-quot -- )
- global [ print-quot call flush ] bind ; inline
+ [ print-quot call flush ] with-global ; inline
! read either a 1 byte or 4 byte big endian integer
: read-var-int ( -- n/f )
IN: namespaces
USE: kernel-internals
-: bind ( ns quot -- )
+: with-variables ( ns quot -- )
swap >n call n> drop ;
"browser-dom" set-in
{ } "" "html" { "string" } alien-invoke ;
: bind-event ( name element quot -- )
- >function swap { } "" "bind" { "string" "function" } alien-invoke ;
+ >function swap { } "" "with-variables" { "string" "function" } alien-invoke ;
"scratchpad" set-in
[
{ { up-axis y-up } { unit-ratio 1 } } [
mesh>sources
- ] bind
+ ] with-variables
]
[ mesh>vertices ]
[ mesh>triangles ] tri ;
[
ascii file-lines [ line>mtl ] each
md
- ] bind ;
+ ] with-variables ;
VERTEX-FORMAT: obj-vertex-format
{ "POSITION" float-components 3 f }
[
[ line>obj ] each-stream-line push-current-model
models get
- ] bind ;
+ ] with-variables ;
] unit-test
[ nothing ] [
- 111 just [ maybe-monad fail ] bind
+ 111 just [ maybe-monad fail ] with-variables
] unit-test
[ 100 ] [
] unit-test
[ { } ] [
- { 1 2 3 } [ drop "OOPS" array-monad fail ] bind
+ { 1 2 3 } [ drop "OOPS" array-monad fail ] with-variables
] unit-test
[ 5 ] [
] unit-test
[ 8 ] [
- 5 state-monad return [ 3 + state-monad return ] bind
+ 5 state-monad return [ 3 + state-monad return ] with-variables
"initial state" run-st
] unit-test
[ 15 ] [
f state-monad return
- [ drop get-st ] bind
- [ 4 + put-st ] bind
- [ drop get-st ] bind
+ [ drop get-st ] with-variables
+ [ 4 + put-st ] with-variables
+ [ drop get-st ] with-variables
11 run-st
] unit-test
] unit-test
[ 6 ] [
- f reader-monad return [ drop ask ] bind [ 1 + ] local 5 run-reader
+ f reader-monad return [ drop ask ] with-variables [ 1 + ] local 5 run-reader
] unit-test
[ f { 1 2 3 } ] [
5 writer-monad return
- [ drop { 1 2 3 } tell ] bind
+ [ drop { 1 2 3 } tell ] with-variables
run-writer
] unit-test
[ cl-current-device set ] when*
[ cl-current-context set ] when*
] 3curry H{ } make-assoc
- ] dip bind ; inline
+ ] dip with-variable ; inline
: cl-platforms ( -- platforms )
0 f 0 uint <ref> [ clGetPlatformIDs cl-success ] keep uint deref
[
stylesheet clone [
[ print-element ] with-default-style
- ] bind
+ ] with-variables
] make-pane
dup page-theme ;
{ "Useful words are " { $link get-global } ", " { $link set-global } }
"Factor idiom for changing a particular namespace"
{ $code """SYMBOL: king
-global [ "Henry VIII" king set ] bind"""
+global [ "Henry VIII" king set ] with-variables"""
}
{ $code "with-scope" }
{ $code "namestack" }