]> gitweb.factorcode.org Git - factor.git/commitdiff
namespaces: adding a "with-global" word to replace "global [ ] bind".
authorJohn Benediktsson <mrjbq7@gmail.com>
Fri, 14 Oct 2011 00:21:59 +0000 (17:21 -0700)
committerJohn Benediktsson <mrjbq7@gmail.com>
Fri, 14 Oct 2011 00:21:59 +0000 (17:21 -0700)
basis/bootstrap/image/image.factor
basis/command-line/command-line.factor
basis/compiler/compiler.factor
basis/debugger/debugger.factor
basis/debugger/threads/threads.factor
basis/http/server/server.factor
basis/smtp/server/server.factor
basis/ui/gestures/gestures.factor
core/namespaces/namespaces.factor
extra/curses/listener/listener.factor
extra/pop3/server/server.factor

index 650bbd8103d0193bfab0414f0c509c1d08e4123a..f7b95657d4b76be39b16ca5a8bf57f4e02a977e7 100755 (executable)
@@ -330,7 +330,7 @@ M: f ' drop \ f type-number ;
 ! Words
 
 : word-sub-primitive ( word -- obj )
-    global [ target-word ] bind sub-primitives get at ;
+    [ target-word ] with-global sub-primitives get at ;
 
 : emit-word ( word -- )
     [
index 4bc899b2f16187ec9ee49a3d473ec394a0335110..fc924b5c2eb5ee2a078949f1dc8b171f1946eeb0 100644 (file)
@@ -62,10 +62,10 @@ SYMBOL: main-vocab-hook
     ] if ;
 
 : default-cli-args ( -- )
-    global [
+    [
         "e" off
         "user-init" on
         main-vocab "run" set
-    ] bind ;
+    ] with-global ;
 
 [ default-cli-args ] "command-line" add-startup-hook
index 0aae136caef29ba5fcef7c20166137e4a51cb7a6..6b10b8cfa4f5eca24682aae06fae598911299d49 100644 (file)
@@ -33,7 +33,7 @@ SYMBOL: compiled
     } 1|| not ;
 
 : compiler-message ( string -- )
-    "trace-compilation" get [ global [ print flush ] bind ] [ drop ] if ;
+    "trace-compilation" get [ [ print flush ] with-global ] [ drop ] if ;
 
 : start ( word -- )
     dup name>> compiler-message
index 0ac1078e93b9c1a6ef3b7f02dec311f5abc62e89..9e800140c1149de5cd1ddd00e89677cc6ef089e3 100755 (executable)
@@ -10,7 +10,7 @@ classes compiler.units generic.standard generic.single vocabs
 init kernel.private io.encodings accessors math.order
 destructors source-files parser classes.tuple.parser
 effects.parser lexer generic.parser strings.parser vocabs.loader
-vocabs.parser source-files.errors ;
+vocabs.parser source-files.errors namespaces ;
 IN: debugger
 
 GENERIC: error-help ( error -- topic )
@@ -65,7 +65,7 @@ M: string error. print ;
 
 : print-error ( error -- )
     [ error. flush ] curry
-    [ global [ "Error in print-error!" print drop ] bind ]
+    [ [ "Error in print-error!" print drop ] with-global ]
     recover ;
 
 : :error ( -- )
index f487c5e01300aada39590b2562ccc2b236208140..3f5a074b25325f10181af9f2e49fe38b122373e9 100644 (file)
@@ -15,12 +15,12 @@ IN: debugger.threads
 ! ( error thread -- )
 [
     dup initial-thread get-global eq? [ die ] [
-        global [
+        [
             error-in-thread. nl
             print-error nl
             :c
             flush
-        ] bind
+        ] with-global
         stop
     ] if
 ] thread-error-hook set-global
index 44ee5f06c3fada93071a496b13b9438c5e0665a2..3f67ad3d8377e26b704031981a85ff48ac5fa427 100644 (file)
@@ -272,7 +272,7 @@ SYMBOL: params
     ] [ [ \ do-request log-error ] [ <500> ] bi ] recover ;
 
 : ?refresh-all ( -- )
-    development? get-global [ global [ refresh-all ] bind ] when ;
+    development? get-global [ [ refresh-all ] with-global ] when ;
 
 LOG: httpd-benchmark DEBUG
 
index dbff4fd214143a27e733be4c4b60c50a1116ddfb..cb4bb753e8d7181a799e8824cf33dcfab93a6e1a 100644 (file)
@@ -66,7 +66,7 @@ SYMBOL: data-mode
                 "220 OK\r\n" write flush t
             ]
         }
-        { [ data-mode get ] [ dup global [ print ] bind t ] }
+        { [ data-mode get ] [ dup [ print ] with-global t ] }
         [ "500 ERROR\r\n" write flush t ]
     } cond nip [ process ] when ;
 
@@ -80,7 +80,7 @@ SYMBOL: data-mode
                     1 minutes timeouts
                     "220 hello\r\n" write flush
                     process
-                    global [ flush ] bind
+                    [ flush ] with-global
                 ] with-stream
             ] with-disposal
         ] with-test-context
index 658e179301c97d25fee8d7cb2a7297e956f0341e..c082c0764e46570e2a2aad5b50c0780013382ca2 100644 (file)
@@ -267,7 +267,7 @@ SYMBOL: drag-timer
     } 0&& nip ;
 
 : update-click# ( button -- )
-    global [
+    [
         dup multi-click? [
             hand-click# inc
         ] [
@@ -275,7 +275,7 @@ SYMBOL: drag-timer
         ] if
         hand-last-button set
         nano-count hand-last-time set
-    ] bind ;
+    ] with-global ;
 
 : update-clicked ( -- )
     hand-gadget get-global hand-clicked set-global
index a100c2d15fca015dafde904c4f8f7b9adb508fe6..38c6870cb8b92e417bd64b7f8d6057967dbe2a65 100644 (file)
@@ -21,11 +21,11 @@ PRIVATE>
 : set ( value variable -- ) namespace set-at ;
 : on ( variable -- ) t swap set ; inline
 : off ( variable -- ) f swap set ; inline
-: get-global ( variable -- value ) global at ;
-: set-global ( value variable -- ) global set-at ;
+: get-global ( variable -- value ) global at ; inline
+: set-global ( value variable -- ) global set-at ; inline
 : change ( variable quot -- ) [ [ get ] keep ] dip dip set ; inline
 : change-global ( variable quot -- ) [ global ] dip change-at ; inline
-: +@ ( n variable -- ) [ 0 or + ] change ;
+: +@ ( n variable -- ) [ 0 or + ] change ; inline
 : inc ( variable -- ) 1 swap +@ ; inline
 : dec ( variable -- ) -1 swap +@ ; inline
 : bind ( ns quot -- ) swap >n call ndrop ; inline
@@ -33,4 +33,5 @@ PRIVATE>
 : 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
 : initialize ( variable quot -- ) [ unless* ] curry change-global ; inline
index 4505c63cbc1aaa09b216b7e26f6aaa6bfacc8f7c..6051b1ca015992392ed0ac67eacce0d1de3b2272 100644 (file)
@@ -59,6 +59,6 @@ INSTANCE: curses-listener-stream plain-writer
     ] with-curses ;
 
 : test-listener ( -- )
-    global [ run-listener ] bind ;
+    [ run-listener ] with-global ;
 
 MAIN: run-listener
index 775a457fc5d00684ea9851147dd3769582c23f7e..aefec65cd395091a445271580c86d3dc4e3b6cbe 100644 (file)
@@ -254,7 +254,7 @@ This is the body of the second test.
                     1 minutes timeouts
                     "+OK POP3 server ready\r\n" write flush
                     process
-                    global [ flush ] bind
+                    [ flush ] with-global
                 ] with-stream
             ] with-disposal
         ] with-test-context