From bf81b19ed7810e7a9db36cb693d661b2c3b8a662 Mon Sep 17 00:00:00 2001
From: Alec Berryman <alec@thened.net>
Date: Tue, 12 May 2009 19:50:19 -0400
Subject: [PATCH 01/23] bloom-filters: fix tests on 64-bit machines

Lose the test that might actually create a very large bit-array and use
a number of elements that will be big enough, whatever the platform.
Now tested on a 64-bit machine.
---
 extra/bloom-filters/bloom-filters-tests.factor | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/extra/bloom-filters/bloom-filters-tests.factor b/extra/bloom-filters/bloom-filters-tests.factor
index 6dce1c2ca9..9b5bf48912 100644
--- a/extra/bloom-filters/bloom-filters-tests.factor
+++ b/extra/bloom-filters/bloom-filters-tests.factor
@@ -24,10 +24,7 @@ IN: bloom-filters.tests
 [ 4 32 ] [ 0.05 5 size-bloom-filter ] unit-test
 
 ! This is a lot of bits.
-: oversized-filter-params ( -- error-rate n-objects )
-    0.00000001 400000000000000 ;
-! [ oversized-filter-params size-bloom-filter ] [ capacity-error? ]  must-fail-with
-! [ oversized-filter-params <bloom-filter> ] [ capacity-error? ] must-fail-with
+[ 0.00000001 max-array-capacity size-bloom-filter ] [ capacity-error? ]  must-fail-with
 
 ! Other error conditions.
 [ 1.0 2000 <bloom-filter> ] [ invalid-error-rate? ] must-fail-with

From 0c1e519dcb8312e9198a14b42faaf3fbf3f0694c Mon Sep 17 00:00:00 2001
From: Slava Pestov <slava@slava-pestovs-macbook-pro.local>
Date: Wed, 13 May 2009 22:15:48 -0500
Subject: [PATCH 02/23] Rename use+ to add-use, move search to vocabs.parser,
 EXCLUDE: bombs out if word doesn't exist

---
 basis/interpolate/interpolate.factor          |  2 +-
 basis/io/sockets/sockets.factor               |  2 +-
 basis/io/sockets/unix/unix.factor             |  2 +-
 basis/listener/listener-tests.factor          |  2 +-
 basis/opengl/gl/extensions/extensions.factor  |  2 +-
 basis/peg/ebnf/ebnf.factor                    |  2 +-
 basis/see/see-docs.factor                     |  2 +-
 basis/tools/test/test.factor                  |  8 ++--
 .../pixel-formats/pixel-formats-docs.factor   |  2 +-
 basis/ui/tools/operations/operations.factor   |  2 +-
 core/parser/parser-docs.factor                | 45 +------------------
 core/parser/parser-tests.factor               | 40 ++++++++++++++++-
 core/parser/parser.factor                     | 15 +------
 core/syntax/syntax.factor                     |  4 +-
 core/vocabs/parser/parser-docs.factor         | 39 +++++++++++++++-
 core/vocabs/parser/parser.factor              | 35 ++++++++++-----
 core/words/words-docs.factor                  |  2 +-
 extra/fuel/eval/eval.factor                   |  2 +-
 extra/sandbox/syntax/syntax.factor            |  2 +-
 19 files changed, 121 insertions(+), 89 deletions(-)

diff --git a/basis/interpolate/interpolate.factor b/basis/interpolate/interpolate.factor
index 1de65fa91f..ea965aac5b 100644
--- a/basis/interpolate/interpolate.factor
+++ b/basis/interpolate/interpolate.factor
@@ -1,6 +1,6 @@
 ! Copyright (C) 2008, 2009 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: io kernel macros make multiline namespaces parser
+USING: io kernel macros make multiline namespaces vocabs.parser
 present sequences strings splitting fry accessors ;
 IN: interpolate
 
diff --git a/basis/io/sockets/sockets.factor b/basis/io/sockets/sockets.factor
index a0beb1f421..0671247ade 100644
--- a/basis/io/sockets/sockets.factor
+++ b/basis/io/sockets/sockets.factor
@@ -12,7 +12,7 @@ IN: io.sockets
 << {
     { [ os windows? ] [ "windows.winsock" ] }
     { [ os unix? ] [ "unix" ] }
-} cond use+ >>
+} cond add-use >>
 
 ! Addressing
 GENERIC: protocol-family ( addrspec -- af )
diff --git a/basis/io/sockets/unix/unix.factor b/basis/io/sockets/unix/unix.factor
index 799dfa78d5..68c7d5c196 100644
--- a/basis/io/sockets/unix/unix.factor
+++ b/basis/io/sockets/unix/unix.factor
@@ -7,7 +7,7 @@ io.backend io.ports io.pathnames io.files.private
 io.encodings.utf8 math.parser continuations libc combinators
 system accessors destructors unix locals init ;
 
-EXCLUDE: io => read write close ;
+EXCLUDE: io => read write ;
 EXCLUDE: io.sockets => accept ;
 
 IN: io.sockets.unix
diff --git a/basis/listener/listener-tests.factor b/basis/listener/listener-tests.factor
index 7ed082234a..9ae5250416 100644
--- a/basis/listener/listener-tests.factor
+++ b/basis/listener/listener-tests.factor
@@ -15,7 +15,7 @@ SYNTAX: hello "Hi" print ;
 ] with-file-vocabs
 
 [
-    "debugger" use+
+    "debugger" add-use
 
     [ [ \ + 1 2 3 4 ] ]
     [
diff --git a/basis/opengl/gl/extensions/extensions.factor b/basis/opengl/gl/extensions/extensions.factor
index ccd3f5fad7..8878e1904a 100644
--- a/basis/opengl/gl/extensions/extensions.factor
+++ b/basis/opengl/gl/extensions/extensions.factor
@@ -9,7 +9,7 @@ ERROR: unknown-gl-platform ;
     { [ os macosx? ]  [ "opengl.gl.macosx" ] }
     { [ os unix? ] [ "opengl.gl.unix" ] }
     [ unknown-gl-platform ]
-} cond use+ >>
+} cond add-use >>
 
 SYMBOL: +gl-function-number-counter+
 SYMBOL: +gl-function-pointers+
diff --git a/basis/peg/ebnf/ebnf.factor b/basis/peg/ebnf/ebnf.factor
index b50ba685b8..fafb846147 100644
--- a/basis/peg/ebnf/ebnf.factor
+++ b/basis/peg/ebnf/ebnf.factor
@@ -5,7 +5,7 @@ sequences quotations vectors namespaces make math assocs
 continuations peg peg.parsers unicode.categories multiline
 splitting accessors effects sequences.deep peg.search
 combinators.short-circuit lexer io.streams.string stack-checker
-io combinators parser summary ;
+io combinators parser vocabs.parser summary ;
 IN: peg.ebnf
 
 : rule ( name word -- parser )
diff --git a/basis/see/see-docs.factor b/basis/see/see-docs.factor
index b2e99843c7..2423950d86 100644
--- a/basis/see/see-docs.factor
+++ b/basis/see/see-docs.factor
@@ -25,7 +25,7 @@ HELP: see-methods
 { $contract "Prettyprints the methods defined on a generic word or class." } ;
 
 HELP: definer
-{ $values { "defspec" "a definition specifier" } { "start" word } { "end" "a word or " { $link f } } }
+{ $values { "defspec" "a definition specifier" } { "start" word } { "end" { $maybe word } } }
 { $contract "Outputs the parsing words which delimit the definition." }
 { $examples
     { $example "USING: definitions prettyprint ;"
diff --git a/basis/tools/test/test.factor b/basis/tools/test/test.factor
index 3dc7b8740b..7b07311ded 100644
--- a/basis/tools/test/test.factor
+++ b/basis/tools/test/test.factor
@@ -2,11 +2,11 @@
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors arrays assocs combinators compiler.units
 continuations debugger effects fry generalizations io io.files
-io.styles kernel lexer locals macros math.parser namespaces
-parser prettyprint quotations sequences source-files splitting
+io.styles kernel lexer locals macros math.parser namespaces parser
+vocabs.parser prettyprint quotations sequences source-files splitting
 stack-checker summary unicode.case vectors vocabs vocabs.loader
-vocabs.files words tools.errors source-files.errors
-io.streams.string make compiler.errors ;
+vocabs.files words tools.errors source-files.errors io.streams.string
+make compiler.errors ;
 IN: tools.test
 
 TUPLE: test-failure < source-file-error continuation ;
diff --git a/basis/ui/pixel-formats/pixel-formats-docs.factor b/basis/ui/pixel-formats/pixel-formats-docs.factor
index 003b205c3d..53e44ec18e 100644
--- a/basis/ui/pixel-formats/pixel-formats-docs.factor
+++ b/basis/ui/pixel-formats/pixel-formats-docs.factor
@@ -6,7 +6,7 @@ IN: ui.pixel-formats
 <<
     "ui.gadgets.worlds" create-vocab drop
     "world" "ui.gadgets.worlds" create drop
-    "ui.gadgets.worlds" (use+)
+    "ui.gadgets.worlds" (add-use)
 >>
 
 ARTICLE: "ui.pixel-formats-attributes" "Pixel format attributes"
diff --git a/basis/ui/tools/operations/operations.factor b/basis/ui/tools/operations/operations.factor
index 650d751ee2..49bb74d18c 100644
--- a/basis/ui/tools/operations/operations.factor
+++ b/basis/ui/tools/operations/operations.factor
@@ -137,7 +137,7 @@ M: word com-stack-effect 1quotation com-stack-effect ;
     { +listener+ t }
 } define-operation
 
-: com-use-vocab ( vocab -- ) vocab-name use+ ;
+: com-use-vocab ( vocab -- ) vocab-name add-use ;
 
 [ vocab-spec? ] \ com-use-vocab H{
     { +secondary+ t }
diff --git a/core/parser/parser-docs.factor b/core/parser/parser-docs.factor
index 98f41ae39a..d6c69f08c2 100644
--- a/core/parser/parser-docs.factor
+++ b/core/parser/parser-docs.factor
@@ -119,45 +119,7 @@ HELP: parser-notes?
 HELP: bad-number
 { $error-description "Indicates the parser encountered an invalid numeric literal." } ;
 
-HELP: use
-{ $var-description "A variable holding the current vocabulary search path as a sequence of assocs." } ;
-
-{ use in use+ (use+) set-use set-in POSTPONE: USING: POSTPONE: USE: with-file-vocabs with-interactive-vocabs } related-words
-
-HELP: in
-{ $var-description "A variable holding the name of the current vocabulary for new definitions." } ;
-
-HELP: current-vocab
-{ $values { "str" "a vocabulary" } }
-{ $description "Returns the vocabulary stored in the " { $link in } " symbol. Throws an error if the current vocabulary is " { $link f } "." } ;
-
-HELP: (use+)
-{ $values { "vocab" "an assoc mapping strings to words" } }
-{ $description "Adds an assoc at the front of the search path." }
-$parsing-note ;
-
-HELP: use+
-{ $values { "vocab" string } }
-{ $description "Adds a new vocabulary at the front of the search path after loading it if necessary. Subsequent word lookups by the parser will search this vocabulary first." }
-$parsing-note
-{ $errors "Throws an error if the vocabulary does not exist." } ;
-
-HELP: set-use
-{ $values { "seq" "a sequence of strings" } }
-{ $description "Sets the vocabulary search path. Later vocabularies take precedence." }
-{ $errors "Throws an error if one of the vocabularies does not exist." }
-$parsing-note ;
-
-HELP: add-use
-{ $values { "seq" "a sequence of strings" } }
-{ $description "Adds multiple vocabularies to the search path, with later vocabularies taking precedence." }
-{ $errors "Throws an error if one of the vocabularies does not exist." }
-$parsing-note ;
-
-HELP: set-in
-{ $values { "name" string } }
-{ $description "Sets the current vocabulary where new words will be defined, creating the vocabulary first if it does not exist." }
-$parsing-note ;
+{ use in add-use (add-use) set-use set-in POSTPONE: USING: POSTPONE: USE: with-file-vocabs with-interactive-vocabs } related-words
 
 HELP: create-in
 { $values { "str" "a word name" } { "word" "a new word" } }
@@ -178,11 +140,6 @@ HELP: no-word
 { $values { "name" string } { "newword" word } }
 { $description "Throws a " { $link no-word-error } "." } ;
 
-HELP: search
-{ $values { "str" string } { "word/f" "a word or " { $link f } } }
-{ $description "Searches for a word by name in the current vocabulary search path. If no such word could be found, outputs " { $link f } "." }
-$parsing-note ;
-
 HELP: scan-word
 { $values { "word/number/f" "a word, number or " { $link f } } }
 { $description "Reads the next token from parser input. If the token is a valid number literal, it is converted to a number, otherwise the dictionary is searched for a word named by the token. Outputs " { $link f } " if the end of the input has been reached." }
diff --git a/core/parser/parser-tests.factor b/core/parser/parser-tests.factor
index e944ecc6f2..4474ed45c4 100644
--- a/core/parser/parser-tests.factor
+++ b/core/parser/parser-tests.factor
@@ -4,7 +4,7 @@ sequences strings io.files io.pathnames definitions
 continuations sorting classes.tuple compiler.units debugger
 vocabs vocabs.loader accessors eval combinators lexer
 vocabs.parser words.symbol multiline source-files.errors
-tools.crossref ;
+tools.crossref grouping ;
 IN: parser.tests
 
 [
@@ -583,3 +583,41 @@ EXCLUDE: qualified.tests.bar => x ;
 
 [ t ] [ "is-not-deferred" "parser.tests" lookup >boolean ] unit-test
 [ t ] [ "is-not-deferred" "parser.tests" lookup deferred? ] unit-test
+
+! Forward-reference resolution case iterated using list in the wrong direction
+[ [ ] ] [
+    "IN: parser.tests.forward-ref-1 DEFER: x DEFER: y"
+    <string-reader> "forward-ref-1" parse-stream
+] unit-test
+
+[ [ ] ] [
+    "IN: parser.tests.forward-ref-2 DEFER: x DEFER: y"
+    <string-reader> "forward-ref-2" parse-stream
+] unit-test
+
+[ [ ] ] [
+    "IN: parser.tests.forward-ref-3 USING: parser.tests.forward-ref-1 parser.tests.forward-ref-2 ; : z ( -- ) x y ;"
+    <string-reader> "forward-ref-3" parse-stream
+] unit-test
+
+[ t ] [
+    "z" "parser.tests.forward-ref-3" lookup def>> [ vocabulary>> ] map all-equal?
+] unit-test
+
+[ [ ] ] [
+    "USING: parser.tests.forward-ref-1 parser.tests.forward-ref-2 ; IN: parser.tests.forward-ref-3 : x ( -- ) ; : z ( -- ) x y ;"
+    <string-reader> "forward-ref-3" parse-stream
+] unit-test
+
+[ f ] [
+    "z" "parser.tests.forward-ref-3" lookup def>> [ vocabulary>> ] map all-equal?
+] unit-test
+
+[ [ ] ] [
+    "IN: parser.tests.forward-ref-3 USING: parser.tests.forward-ref-1 parser.tests.forward-ref-2 ; : z ( -- ) x y ;"
+    <string-reader> "forward-ref-3" parse-stream
+] unit-test
+
+[ t ] [
+    "z" "parser.tests.forward-ref-3" lookup def>> [ vocabulary>> ] map all-equal?
+] unit-test
\ No newline at end of file
diff --git a/core/parser/parser.factor b/core/parser/parser.factor
index 01e0b18887..d802fd72fa 100644
--- a/core/parser/parser.factor
+++ b/core/parser/parser.factor
@@ -55,7 +55,7 @@ SYMBOL: auto-use?
 : no-word-restarted ( restart-value -- word )
     dup word? [
         dup vocabulary>>
-        [ (use+) ]
+        [ (add-use) ]
         [ amended-use get dup [ push ] [ 2drop ] if ]
         [ "Added \"" "\" vocabulary to search path" surround note. ]
         tri
@@ -68,19 +68,6 @@ SYMBOL: auto-use?
     [ <no-word-error> throw-restarts no-word-restarted ]
     if ;
 
-: check-forward ( str word -- word/f )
-    dup forward-reference? [
-        drop
-        use get
-        [ at ] with map sift
-        [ forward-reference? not ] find nip
-    ] [
-        nip
-    ] if ;
-
-: search ( str -- word/f )
-    dup use get assoc-stack check-forward ;
-
 : scan-word ( -- word/number/f )
     scan dup [
         dup search [ ] [
diff --git a/core/syntax/syntax.factor b/core/syntax/syntax.factor
index 7d710717aa..8d52a2c786 100644
--- a/core/syntax/syntax.factor
+++ b/core/syntax/syntax.factor
@@ -49,9 +49,9 @@ IN: bootstrap.syntax
         POSTPONE: PRIVATE> in get ".private" append set-in
     ] define-core-syntax
 
-    "USE:" [ scan use+ ] define-core-syntax
+    "USE:" [ scan add-use ] define-core-syntax
 
-    "USING:" [ ";" parse-tokens add-use ] define-core-syntax
+    "USING:" [ ";" parse-tokens [ add-use ] each ] define-core-syntax
 
     "QUALIFIED:" [ scan dup add-qualified ] define-core-syntax
 
diff --git a/core/vocabs/parser/parser-docs.factor b/core/vocabs/parser/parser-docs.factor
index 71862402cd..d61c998725 100644
--- a/core/vocabs/parser/parser-docs.factor
+++ b/core/vocabs/parser/parser-docs.factor
@@ -1,4 +1,4 @@
-USING: help.markup help.syntax parser ;
+USING: help.markup help.syntax parser strings words ;
 IN: vocabs.parser
 
 ARTICLE: "vocabulary-search-shadow" "Shadowing word names"
@@ -78,3 +78,40 @@ $nl
 { $see-also "words" } ;
 
 ABOUT: "vocabulary-search"
+
+HELP: use
+{ $var-description "A variable holding the current vocabulary search path as a sequence of assocs." } ;
+
+HELP: in
+{ $var-description "A variable holding the name of the current vocabulary for new definitions." } ;
+
+HELP: current-vocab
+{ $values { "str" "a vocabulary" } }
+{ $description "Returns the vocabulary stored in the " { $link in } " symbol. Throws an error if the current vocabulary is " { $link f } "." } ;
+
+HELP: (add-use)
+{ $values { "vocab" "an assoc mapping strings to words" } }
+{ $description "Adds an assoc at the front of the search path." }
+$parsing-note ;
+
+HELP: add-use
+{ $values { "vocab" string } }
+{ $description "Adds a new vocabulary at the front of the search path after loading it if necessary. Subsequent word lookups by the parser will search this vocabulary first." }
+$parsing-note
+{ $errors "Throws an error if the vocabulary does not exist." } ;
+
+HELP: set-use
+{ $values { "seq" "a sequence of strings" } }
+{ $description "Sets the vocabulary search path. Later vocabularies take precedence." }
+{ $errors "Throws an error if one of the vocabularies does not exist." }
+$parsing-note ;
+
+HELP: set-in
+{ $values { "name" string } }
+{ $description "Sets the current vocabulary where new words will be defined, creating the vocabulary first if it does not exist." }
+$parsing-note ;
+
+HELP: search
+{ $values { "str" string } { "word/f" { $maybe word } } }
+{ $description "Searches for a word by name in the current vocabulary search path. If no such word could be found, outputs " { $link f } "." }
+$parsing-note ;
diff --git a/core/vocabs/parser/parser.factor b/core/vocabs/parser/parser.factor
index e8783c0dbe..d5978270dc 100644
--- a/core/vocabs/parser/parser.factor
+++ b/core/vocabs/parser/parser.factor
@@ -2,7 +2,7 @@
 ! Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: assocs hashtables kernel namespaces sequences
-sets strings vocabs sorting accessors arrays ;
+sets strings vocabs sorting accessors arrays compiler.units ;
 IN: vocabs.parser
 
 ERROR: no-word-error name ;
@@ -19,13 +19,11 @@ ERROR: no-word-error name ;
 SYMBOL: use
 SYMBOL: in
 
-: (use+) ( vocab -- )
+: (add-use) ( vocab -- )
     vocab-words use get push ;
 
-: use+ ( vocab -- )
-    load-vocab (use+) ;
-
-: add-use ( seq -- ) [ use+ ] each ;
+: add-use ( vocab -- )
+    load-vocab (add-use) ;
 
 : set-use ( seq -- )
     [ vocab-words ] V{ } map-as sift use set ;
@@ -35,15 +33,17 @@ SYMBOL: in
     [ swap [ prepend ] dip ] curry assoc-map
     use get push ;
 
-: partial-vocab ( words vocab -- assoc )
-    load-vocab vocab-words
+: words-named-in ( words assoc -- assoc' )
     [ dupd at [ no-word-error ] unless* ] curry { } map>assoc ;
 
+: partial-vocab-including ( words vocab -- assoc )
+    load-vocab vocab-words words-named-in ;
+
 : add-words-from ( words vocab -- )
-    partial-vocab use get push ;
+    partial-vocab-including use get push ;
 
 : partial-vocab-excluding ( words vocab -- assoc )
-    load-vocab [ vocab-words keys swap diff ] keep partial-vocab ;
+    load-vocab vocab-words [ nip ] [ words-named-in ] 2bi assoc-diff ;
 
 : add-words-excluding ( words vocab -- )
     partial-vocab-excluding use get push ;
@@ -56,4 +56,17 @@ SYMBOL: in
     dup string? [ "Vocabulary name must be a string" throw ] unless ;
 
 : set-in ( name -- )
-    check-vocab-string dup in set create-vocab (use+) ;
\ No newline at end of file
+    check-vocab-string dup in set create-vocab (add-use) ;
+
+: check-forward ( str word -- word/f )
+    dup forward-reference? [
+        drop
+        use get
+        [ at ] with map sift
+        [ forward-reference? not ] find-last nip
+    ] [
+        nip
+    ] if ;
+
+: search ( str -- word/f )
+    dup use get assoc-stack check-forward ;
\ No newline at end of file
diff --git a/core/words/words-docs.factor b/core/words/words-docs.factor
index 3725086f70..a04b95bcfd 100644
--- a/core/words/words-docs.factor
+++ b/core/words/words-docs.factor
@@ -237,7 +237,7 @@ HELP: set-word
 { $description "Sets the recently defined word." } ;
 
 HELP: lookup
-{ $values { "name" string } { "vocab" string } { "word" "a word or " { $link f } } }
+{ $values { "name" string } { "vocab" string } { "word" { $maybe word } } }
 { $description "Looks up a word in the dictionary. If the vocabulary or the word is not defined, outputs " { $link f } "." } ;
 
 HELP: reveal
diff --git a/extra/fuel/eval/eval.factor b/extra/fuel/eval/eval.factor
index 3f7ce863c7..9f0b6fc0a3 100644
--- a/extra/fuel/eval/eval.factor
+++ b/extra/fuel/eval/eval.factor
@@ -60,7 +60,7 @@ t fuel-eval-res-flag set-global
     [ print-error ] recover ;
 
 : (fuel-eval-usings) ( usings -- )
-    [ [ use+ ] curry [ drop ] recover ] each
+    [ [ add-use ] curry [ drop ] recover ] each
     fuel-forget-error fuel-forget-output ;
 
 : (fuel-eval-in) ( in -- )
diff --git a/extra/sandbox/syntax/syntax.factor b/extra/sandbox/syntax/syntax.factor
index 2ff5f070c7..f04b05acd8 100644
--- a/extra/sandbox/syntax/syntax.factor
+++ b/extra/sandbox/syntax/syntax.factor
@@ -9,7 +9,7 @@ IN: sandbox.syntax
 ERROR: sandbox-error vocab ;
 
 : sandbox-use+ ( alias -- )
-    dup whitelist get at [ use+ ] [ sandbox-error ] ?if ;
+    dup whitelist get at [ add-use ] [ sandbox-error ] ?if ;
 
 PRIVATE>
 

From 2ad45a24b38ea53467dd683c37cddc34ec115e90 Mon Sep 17 00:00:00 2001
From: Slava Pestov <slava@slava-pestovs-macbook-pro.local>
Date: Wed, 13 May 2009 22:42:38 -0500
Subject: [PATCH 03/23] ui.tools.debugger: don't throw an error if world has no
 children

---
 basis/ui/tools/debugger/debugger.factor | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/basis/ui/tools/debugger/debugger.factor b/basis/ui/tools/debugger/debugger.factor
index f3f533e681..2c653266e5 100755
--- a/basis/ui/tools/debugger/debugger.factor
+++ b/basis/ui/tools/debugger/debugger.factor
@@ -60,7 +60,8 @@ M: debugger focusable-child*
 
 GENERIC: error-in-debugger? ( error -- ? )
 
-M: world-error error-in-debugger? world>> gadget-child debugger? ;
+M: world-error error-in-debugger?
+    world>> children>> [ f ] [ first debugger? ] if-empty ;
 
 M: object error-in-debugger? drop f ;
 

From fb6df472a208339cca3758f5bd47221bcb691f65 Mon Sep 17 00:00:00 2001
From: Slava Pestov <slava@slava-pestovs-macbook-pro.local>
Date: Thu, 14 May 2009 16:54:16 -0500
Subject: [PATCH 04/23] Cleaning up USING: lists for new strict semantics

---
 basis/alien/c-types/c-types.factor                  | 10 +++++-----
 basis/bootstrap/compiler/compiler.factor            |  9 +++++----
 basis/bootstrap/image/image.factor                  |  2 +-
 basis/calendar/format/format.factor                 |  2 +-
 basis/compiler/cfg/rpo/rpo.factor                   |  2 +-
 basis/compiler/compiler.factor                      |  2 +-
 basis/compiler/tree/debugger/debugger.factor        |  1 +
 basis/compiler/tree/def-use/def-use.factor          |  2 +-
 .../tree/normalization/normalization.factor         |  2 +-
 basis/compiler/tree/propagation/nodes/nodes.factor  |  2 +-
 basis/concurrency/messaging/messaging-docs.factor   |  2 +-
 basis/documents/documents.factor                    |  1 +
 basis/editors/editors.factor                        |  2 +-
 basis/environment/unix/unix.factor                  |  3 +--
 basis/help/cookbook/cookbook.factor                 |  2 +-
 basis/http/client/client-docs.factor                |  2 +-
 basis/http/client/client.factor                     |  2 +-
 basis/http/parsers/parsers.factor                   |  2 +-
 basis/images/tesselation/tesselation.factor         |  2 +-
 basis/io/buffers/buffers.factor                     |  2 +-
 basis/io/launcher/unix/unix.factor                  |  5 +----
 basis/io/sockets/secure/unix/unix.factor            |  1 +
 basis/io/sockets/sockets.factor                     | 13 ++++++-------
 basis/io/sockets/unix/unix.factor                   | 12 ++++++------
 basis/logging/server/server.factor                  |  8 ++++----
 basis/models/range/range.factor                     |  1 +
 basis/opengl/textures/textures.factor               |  2 +-
 basis/peg/ebnf/ebnf.factor                          |  8 +++++---
 basis/peg/peg.factor                                |  2 +-
 basis/prettyprint/prettyprint-docs.factor           |  2 +-
 .../random/mersenne-twister/mersenne-twister.factor |  2 --
 basis/random/random.factor                          |  2 --
 basis/stack-checker/inlining/inlining.factor        |  2 +-
 basis/stack-checker/known-words/known-words.factor  |  4 ++--
 basis/stack-checker/transforms/transforms.factor    |  2 +-
 basis/ui/commands/commands.factor                   |  2 +-
 basis/ui/gadgets/buttons/buttons.factor             |  1 +
 basis/ui/gadgets/editors/editors.factor             |  2 +-
 basis/ui/gadgets/gadgets.factor                     |  2 +-
 basis/ui/gadgets/glass/glass.factor                 |  1 +
 basis/ui/gadgets/menus/menus.factor                 |  2 +-
 basis/ui/gadgets/panes/panes.factor                 |  1 +
 basis/ui/gadgets/tables/tables.factor               |  2 +-
 basis/ui/tools/browser/browser.factor               | 11 ++++++-----
 basis/ui/tools/browser/popups/popups.factor         |  1 +
 basis/ui/tools/debugger/debugger-docs.factor        |  2 +-
 basis/ui/tools/debugger/debugger.factor             |  2 +-
 basis/ui/tools/deploy/deploy.factor                 | 13 ++++++-------
 basis/ui/tools/error-list/error-list.factor         |  2 +-
 basis/ui/tools/profiler/profiler.factor             |  7 +++----
 basis/ui/ui.factor                                  |  2 +-
 basis/unix/debugger/debugger.factor                 |  3 ++-
 basis/unix/process/process.factor                   |  2 +-
 basis/unix/stat/stat.factor                         |  4 ----
 basis/unix/types/types.factor                       |  3 +--
 basis/unix/unix.factor                              |  3 ++-
 core/kernel/kernel-docs.factor                      |  2 +-
 core/slots/slots-docs.factor                        |  9 ++++-----
 58 files changed, 98 insertions(+), 101 deletions(-)

diff --git a/basis/alien/c-types/c-types.factor b/basis/alien/c-types/c-types.factor
index df5a5bbba8..6e398667ec 100755
--- a/basis/alien/c-types/c-types.factor
+++ b/basis/alien/c-types/c-types.factor
@@ -1,11 +1,11 @@
 ! Copyright (C) 2004, 2009 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: byte-arrays arrays assocs kernel kernel.private libc math
-namespaces make parser sequences strings words assocs splitting
-math.parser cpu.architecture alien alien.accessors alien.strings
-quotations layouts system compiler.units io io.files
-io.encodings.binary io.streams.memory accessors combinators effects
-continuations fry classes ;
+namespaces make parser sequences strings words splitting math.parser
+cpu.architecture alien alien.accessors alien.strings quotations
+layouts system compiler.units io io.files io.encodings.binary
+io.streams.memory accessors combinators effects continuations fry
+classes ;
 IN: alien.c-types
 
 DEFER: <int>
diff --git a/basis/bootstrap/compiler/compiler.factor b/basis/bootstrap/compiler/compiler.factor
index 3aefdec29f..5e3827efea 100755
--- a/basis/bootstrap/compiler/compiler.factor
+++ b/basis/bootstrap/compiler/compiler.factor
@@ -1,13 +1,14 @@
 ! Copyright (C) 2007, 2009 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors compiler cpu.architecture vocabs.loader system
+USING: accessors cpu.architecture vocabs.loader system
 sequences namespaces parser kernel kernel.private classes
 classes.private arrays hashtables vectors classes.tuple sbufs
 hashtables.private sequences.private math classes.tuple.private
 growable namespaces.private assocs words command-line vocabs io
-io.encodings.string libc splitting math.parser memory
-compiler.units math.order compiler.tree.builder
-compiler.tree.optimizer compiler.cfg.optimizer ;
+io.encodings.string libc splitting math.parser memory compiler.units
+math.order compiler.tree.builder compiler.tree.optimizer
+compiler.cfg.optimizer ;
+FROM: compiler => enable-optimizer compile-word ;
 IN: bootstrap.compiler
 
 ! Don't bring this in when deploying, since it will store a
diff --git a/basis/bootstrap/image/image.factor b/basis/bootstrap/image/image.factor
index 4a7a558703..68c7b23302 100644
--- a/basis/bootstrap/image/image.factor
+++ b/basis/bootstrap/image/image.factor
@@ -1,6 +1,6 @@
 ! Copyright (C) 2004, 2009 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: alien arrays byte-arrays generic assocs hashtables assocs
+USING: alien arrays byte-arrays generic hashtables
 hashtables.private io io.binary io.files io.encodings.binary
 io.pathnames kernel kernel.private math namespaces make parser
 prettyprint sequences sequences.private strings sbufs vectors words
diff --git a/basis/calendar/format/format.factor b/basis/calendar/format/format.factor
index c2e95f2a9e..ad43cc2f1d 100644
--- a/basis/calendar/format/format.factor
+++ b/basis/calendar/format/format.factor
@@ -2,7 +2,7 @@
 ! See http://factorcode.org/license.txt for BSD license.
 USING: math math.order math.parser math.functions kernel
 sequences io accessors arrays io.streams.string splitting
-combinators accessors calendar calendar.format.macros present ;
+combinators calendar calendar.format.macros present ;
 IN: calendar.format
 
 : pad-00 ( n -- str ) number>string 2 CHAR: 0 pad-head ;
diff --git a/basis/compiler/cfg/rpo/rpo.factor b/basis/compiler/cfg/rpo/rpo.factor
index 158903b4bf..bb4153da78 100644
--- a/basis/compiler/cfg/rpo/rpo.factor
+++ b/basis/compiler/cfg/rpo/rpo.factor
@@ -1,7 +1,7 @@
 ! Copyright (C) 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: kernel accessors namespaces make math sequences sets
-assocs fry compiler.cfg.instructions ;
+assocs fry compiler.cfg compiler.cfg.instructions ;
 IN: compiler.cfg.rpo
 
 SYMBOL: visited
diff --git a/basis/compiler/compiler.factor b/basis/compiler/compiler.factor
index 01e58461ff..c3d70fdc5b 100644
--- a/basis/compiler/compiler.factor
+++ b/basis/compiler/compiler.factor
@@ -2,7 +2,7 @@
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors kernel namespaces arrays sequences io words fry
 continuations vocabs assocs dlists definitions math graphs generic
-generic.single combinators deques search-deques macros io
+generic.single combinators deques search-deques macros
 source-files.errors stack-checker stack-checker.state
 stack-checker.inlining stack-checker.errors combinators.short-circuit
 compiler.errors compiler.units compiler.tree.builder
diff --git a/basis/compiler/tree/debugger/debugger.factor b/basis/compiler/tree/debugger/debugger.factor
index 60cab92843..d1a9f5215a 100644
--- a/basis/compiler/tree/debugger/debugger.factor
+++ b/basis/compiler/tree/debugger/debugger.factor
@@ -16,6 +16,7 @@ compiler.tree.builder
 compiler.tree.optimizer
 compiler.tree.combinators
 compiler.tree.checker ;
+FROM: fry => _ ;
 RENAME: _ match => __
 IN: compiler.tree.debugger
 
diff --git a/basis/compiler/tree/def-use/def-use.factor b/basis/compiler/tree/def-use/def-use.factor
index 705f44eeb6..fa504919a3 100644
--- a/basis/compiler/tree/def-use/def-use.factor
+++ b/basis/compiler/tree/def-use/def-use.factor
@@ -1,6 +1,6 @@
 ! Copyright (C) 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: arrays namespaces assocs sequences kernel generic assocs
+USING: arrays namespaces sequences kernel generic assocs
 classes vectors accessors combinators sets
 stack-checker.state
 stack-checker.branches
diff --git a/basis/compiler/tree/normalization/normalization.factor b/basis/compiler/tree/normalization/normalization.factor
index ee7bf8672e..7494ed064e 100644
--- a/basis/compiler/tree/normalization/normalization.factor
+++ b/basis/compiler/tree/normalization/normalization.factor
@@ -1,7 +1,7 @@
 ! Copyright (C) 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: fry namespaces sequences math math.order accessors kernel arrays
-combinators compiler.utilities assocs
+combinators assocs
 stack-checker.backend
 stack-checker.branches
 stack-checker.inlining
diff --git a/basis/compiler/tree/propagation/nodes/nodes.factor b/basis/compiler/tree/propagation/nodes/nodes.factor
index d676102bde..c3f5312601 100644
--- a/basis/compiler/tree/propagation/nodes/nodes.factor
+++ b/basis/compiler/tree/propagation/nodes/nodes.factor
@@ -1,6 +1,6 @@
 ! Copyright (C) 2004, 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: sequences accessors kernel assocs sequences
+USING: sequences accessors kernel assocs
 compiler.tree
 compiler.tree.propagation.copy
 compiler.tree.propagation.info ;
diff --git a/basis/concurrency/messaging/messaging-docs.factor b/basis/concurrency/messaging/messaging-docs.factor
index 41beedb6dc..039e9a53af 100644
--- a/basis/concurrency/messaging/messaging-docs.factor
+++ b/basis/concurrency/messaging/messaging-docs.factor
@@ -1,7 +1,7 @@
 ! Copyright (C) 2006 Chris Double.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: help.syntax help.markup concurrency.messaging.private
-threads kernel arrays quotations threads strings ;
+threads kernel arrays quotations strings ;
 IN: concurrency.messaging
 
 HELP: send
diff --git a/basis/documents/documents.factor b/basis/documents/documents.factor
index 451c912779..104dea6b98 100644
--- a/basis/documents/documents.factor
+++ b/basis/documents/documents.factor
@@ -3,6 +3,7 @@
 USING: accessors arrays io kernel math models namespaces make
 sequences strings splitting combinators unicode.categories
 math.order math.ranges fry locals ;
+FROM: models => change-model ;
 IN: documents
 
 : +col ( loc n -- newloc ) [ first2 ] dip + 2array ;
diff --git a/basis/editors/editors.factor b/basis/editors/editors.factor
index d5b4b909e3..f81490bcf2 100644
--- a/basis/editors/editors.factor
+++ b/basis/editors/editors.factor
@@ -4,7 +4,7 @@ USING: parser lexer kernel namespaces sequences definitions
 io.files io.backend io.pathnames io summary continuations
 tools.crossref vocabs.hierarchy prettyprint source-files
 source-files.errors assocs vocabs vocabs.loader splitting
-accessors debugger prettyprint help.topics ;
+accessors debugger help.topics ;
 IN: editors
 
 TUPLE: no-edit-hook ;
diff --git a/basis/environment/unix/unix.factor b/basis/environment/unix/unix.factor
index 7da19ee47b..84dfbbd43e 100644
--- a/basis/environment/unix/unix.factor
+++ b/basis/environment/unix/unix.factor
@@ -2,8 +2,7 @@
 ! See http://factorcode.org/license.txt for BSD license.
 USING: alien alien.c-types alien.strings alien.syntax kernel
 layouts sequences system unix environment io.encodings.utf8
-unix.utilities vocabs.loader combinators alien.accessors
-alien.syntax ;
+unix.utilities vocabs.loader combinators alien.accessors ;
 IN: environment.unix
 
 HOOK: environ os ( -- void* )
diff --git a/basis/help/cookbook/cookbook.factor b/basis/help/cookbook/cookbook.factor
index 59486a9c35..8aa0265239 100644
--- a/basis/help/cookbook/cookbook.factor
+++ b/basis/help/cookbook/cookbook.factor
@@ -1,4 +1,4 @@
-USING: help.markup help.syntax io kernel math namespaces parser
+USING: help.markup help.syntax io kernel math parser
 prettyprint sequences vocabs.loader namespaces stack-checker
 help command-line multiline see ;
 IN: help.cookbook
diff --git a/basis/http/client/client-docs.factor b/basis/http/client/client-docs.factor
index e00f8e2263..890518aa2a 100644
--- a/basis/http/client/client-docs.factor
+++ b/basis/http/client/client-docs.factor
@@ -1,5 +1,5 @@
 USING: http help.markup help.syntax io.pathnames io.streams.string
-io.encodings.8-bit io.encodings.binary kernel strings urls
+io.encodings.8-bit io.encodings.binary kernel urls
 urls.encoding byte-arrays strings assocs sequences destructors
 http.client.post-data.private ;
 IN: http.client
diff --git a/basis/http/client/client.factor b/basis/http/client/client.factor
index d1997c73f9..2f6bcfafe9 100644
--- a/basis/http/client/client.factor
+++ b/basis/http/client/client.factor
@@ -1,6 +1,6 @@
 ! Copyright (C) 2005, 2009 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors assocs kernel math math.parser namespaces make
+USING: assocs kernel math math.parser namespaces make
 sequences strings splitting calendar continuations accessors vectors
 math.order hashtables byte-arrays destructors
 io io.sockets io.streams.string io.files io.timeouts
diff --git a/basis/http/parsers/parsers.factor b/basis/http/parsers/parsers.factor
index 2520c35acb..1810617c56 100644
--- a/basis/http/parsers/parsers.factor
+++ b/basis/http/parsers/parsers.factor
@@ -2,7 +2,7 @@
 ! See http://factorcode.org/license.txt for BSD license.
 USING: combinators.short-circuit math math.order math.parser
 kernel sequences sequences.deep peg peg.parsers assocs arrays
-hashtables strings unicode.case namespaces make ascii ;
+hashtables strings namespaces make ascii ;
 IN: http.parsers
 
 : except ( quot -- parser )
diff --git a/basis/images/tesselation/tesselation.factor b/basis/images/tesselation/tesselation.factor
index 694041a28d..cbdf396b48 100644
--- a/basis/images/tesselation/tesselation.factor
+++ b/basis/images/tesselation/tesselation.factor
@@ -1,7 +1,7 @@
 ! Copyright (C) 2009 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: sequences kernel math grouping fry columns locals accessors
-images math math.vectors arrays ;
+images math.vectors arrays ;
 IN: images.tesselation
 
 : group-rows ( bitmap bitmap-dim -- rows )
diff --git a/basis/io/buffers/buffers.factor b/basis/io/buffers/buffers.factor
index 49b5357d98..c9396dd081 100644
--- a/basis/io/buffers/buffers.factor
+++ b/basis/io/buffers/buffers.factor
@@ -3,7 +3,7 @@
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors alien alien.accessors alien.c-types
 alien.syntax kernel libc math sequences byte-arrays strings
-hints accessors math.order destructors combinators ;
+hints math.order destructors combinators ;
 IN: io.buffers
 
 TUPLE: buffer
diff --git a/basis/io/launcher/unix/unix.factor b/basis/io/launcher/unix/unix.factor
index 5d7502f681..5424ab4238 100644
--- a/basis/io/launcher/unix/unix.factor
+++ b/basis/io/launcher/unix/unix.factor
@@ -4,13 +4,10 @@ USING: accessors alien.c-types arrays assocs combinators
 continuations environment io io.backend io.backend.unix
 io.files io.files.private io.files.unix io.launcher
 io.launcher.unix.parser io.pathnames io.ports kernel math
-namespaces sequences strings system threads unix unix
+namespaces sequences strings system threads unix
 unix.process ;
 IN: io.launcher.unix
 
-! Search unix first
-USE: unix
-
 : get-arguments ( process -- seq )
     command>> dup string? [ tokenize-command ] when ;
 
diff --git a/basis/io/sockets/secure/unix/unix.factor b/basis/io/sockets/secure/unix/unix.factor
index f1f39a0559..6580af891d 100644
--- a/basis/io/sockets/secure/unix/unix.factor
+++ b/basis/io/sockets/secure/unix/unix.factor
@@ -7,6 +7,7 @@ openssl.libcrypto openssl.libssl io io.files io.ports
 io.backend.unix io.sockets.unix io.encodings.ascii io.buffers
 io.sockets io.sockets.secure io.sockets.secure.openssl
 io.timeouts system summary fry ;
+FROM: io.ports => shutdown ;
 IN: io.sockets.secure.unix
 
 M: ssl-handle handle-fd file>> handle-fd ;
diff --git a/basis/io/sockets/sockets.factor b/basis/io/sockets/sockets.factor
index 0671247ade..d6a8d1b54e 100644
--- a/basis/io/sockets/sockets.factor
+++ b/basis/io/sockets/sockets.factor
@@ -1,18 +1,17 @@
 ! Copyright (C) 2007, 2008 Slava Pestov, Doug Coleman,
 ! Daniel Ehrenberg.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: generic kernel io.backend namespaces continuations
-sequences arrays io.encodings io.ports io.streams.duplex
-io.encodings.ascii alien.strings io.binary accessors destructors
-classes byte-arrays system combinators parser
-alien.c-types math.parser splitting grouping math assocs summary
-system vocabs.loader combinators present fry vocabs.parser ;
+USING: generic kernel io.backend namespaces continuations sequences
+arrays io.encodings io.ports io.streams.duplex io.encodings.ascii
+alien.strings io.binary accessors destructors classes byte-arrays
+parser alien.c-types math.parser splitting grouping math assocs
+summary system vocabs.loader combinators present fry vocabs.parser ;
 IN: io.sockets
 
 << {
     { [ os windows? ] [ "windows.winsock" ] }
     { [ os unix? ] [ "unix" ] }
-} cond add-use >>
+} cond add-ambiguous-use >>
 
 ! Addressing
 GENERIC: protocol-family ( addrspec -- af )
diff --git a/basis/io/sockets/unix/unix.factor b/basis/io/sockets/unix/unix.factor
index 68c7d5c196..6ba7ca2322 100644
--- a/basis/io/sockets/unix/unix.factor
+++ b/basis/io/sockets/unix/unix.factor
@@ -1,12 +1,12 @@
 ! Copyright (C) 2004, 2008 Slava Pestov, Ivan Tikhonov. 
 ! See http://factorcode.org/license.txt for BSD license.
-USING: alien alien.c-types alien.strings generic kernel math
-namespaces threads sequences byte-arrays io.ports
-io.binary io.backend.unix io.streams.duplex
-io.backend io.ports io.pathnames io.files.private
-io.encodings.utf8 math.parser continuations libc combinators
-system accessors destructors unix locals init ;
+USING: alien alien.c-types alien.strings generic kernel math threads
+sequences byte-arrays io.ports io.binary io.backend.unix
+io.streams.duplex io.backend io.ports io.pathnames io.files.private
+io.encodings.utf8 math.parser continuations libc combinators system
+accessors destructors unix locals init ;
 
+EXCLUDE: namespaces => bind ;
 EXCLUDE: io => read write ;
 EXCLUDE: io.sockets => accept ;
 
diff --git a/basis/logging/server/server.factor b/basis/logging/server/server.factor
index 7dced852fd..8374ab421b 100644
--- a/basis/logging/server/server.factor
+++ b/basis/logging/server/server.factor
@@ -1,10 +1,10 @@
 ! Copyright (C) 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: namespaces kernel io io.files io.pathnames io.directories
-io.sockets io.encodings.utf8
-calendar calendar.format sequences continuations destructors
-prettyprint assocs math.parser words debugger math combinators
-concurrency.messaging threads arrays init math.ranges strings ;
+io.encodings.utf8 calendar calendar.format sequences continuations
+destructors prettyprint assocs math.parser words debugger math
+combinators concurrency.messaging threads arrays init math.ranges
+strings ;
 IN: logging.server
 
 : log-root ( -- string )
diff --git a/basis/models/range/range.factor b/basis/models/range/range.factor
index a1abd9aeea..c8bc8d8e54 100644
--- a/basis/models/range/range.factor
+++ b/basis/models/range/range.factor
@@ -2,6 +2,7 @@
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors kernel models arrays sequences math math.order
 models.product ;
+FROM: models.product => product ;
 IN: models.range
 
 TUPLE: range < product ;
diff --git a/basis/opengl/textures/textures.factor b/basis/opengl/textures/textures.factor
index 49725d2242..f0edab23a3 100755
--- a/basis/opengl/textures/textures.factor
+++ b/basis/opengl/textures/textures.factor
@@ -1,6 +1,6 @@
 ! Copyright (C) 2009 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors assocs cache colors.constants destructors fry kernel
+USING: accessors assocs cache colors.constants destructors kernel
 opengl opengl.gl opengl.capabilities combinators images
 images.tesselation grouping specialized-arrays.float sequences math
 math.vectors math.matrices generalizations fry arrays namespaces
diff --git a/basis/peg/ebnf/ebnf.factor b/basis/peg/ebnf/ebnf.factor
index fafb846147..94df4ca209 100644
--- a/basis/peg/ebnf/ebnf.factor
+++ b/basis/peg/ebnf/ebnf.factor
@@ -1,11 +1,13 @@
 ! Copyright (C) 2007 Chris Double.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: kernel compiler.units words arrays strings math.parser
+USING: kernel words arrays strings math.parser
 sequences quotations vectors namespaces make math assocs
 continuations peg peg.parsers unicode.categories multiline
 splitting accessors effects sequences.deep peg.search
 combinators.short-circuit lexer io.streams.string stack-checker
-io combinators parser vocabs.parser summary ;
+io combinators parser summary ;
+FROM: compiler.units => with-compilation-unit ;
+FROM: vocabs.parser => search ;
 IN: peg.ebnf
 
 : rule ( name word -- parser )
@@ -441,7 +443,7 @@ M: ebnf-sequence build-locals ( code ast -- code )
       drop 
     ] [ 
       [
-        "USING: locals sequences ;  [let* | " %
+        "FROM: locals => [let* ; FROM: sequences => nth ; [let* | " %
           dup length swap [
             dup ebnf-var? [
               name>> % 
diff --git a/basis/peg/peg.factor b/basis/peg/peg.factor
index dda36432e7..c76ca7ac9c 100644
--- a/basis/peg/peg.factor
+++ b/basis/peg/peg.factor
@@ -1,7 +1,7 @@
 ! Copyright (C) 2007, 2008 Chris Double.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: kernel sequences strings fry namespaces make math assocs
-io vectors arrays math.parser math.order vectors combinators
+io vectors arrays math.parser math.order combinators
 classes sets unicode.categories compiler.units parser words
 quotations effects memoize accessors locals effects splitting
 combinators.short-circuit generalizations ;
diff --git a/basis/prettyprint/prettyprint-docs.factor b/basis/prettyprint/prettyprint-docs.factor
index f938ab30f7..1af921d4f3 100644
--- a/basis/prettyprint/prettyprint-docs.factor
+++ b/basis/prettyprint/prettyprint-docs.factor
@@ -1,5 +1,5 @@
 USING: prettyprint.backend prettyprint.config prettyprint.custom
-prettyprint.sections prettyprint.private help.markup help.syntax
+prettyprint.sections help.markup help.syntax
 io kernel words definitions quotations strings generic classes
 prettyprint.private ;
 IN: prettyprint
diff --git a/basis/random/mersenne-twister/mersenne-twister.factor b/basis/random/mersenne-twister/mersenne-twister.factor
index 361ba7719e..a02abbb8ac 100644
--- a/basis/random/mersenne-twister/mersenne-twister.factor
+++ b/basis/random/mersenne-twister/mersenne-twister.factor
@@ -69,8 +69,6 @@ M: mersenne-twister random-32* ( mt -- r )
     [ seq>> nth-unsafe mt-temper ]
     [ [ 1+ ] change-i drop ] tri ;
 
-USE: init
-
 [
     [ 32 random-bits ] with-system-random
     <mersenne-twister> random-generator set-global
diff --git a/basis/random/random.factor b/basis/random/random.factor
index 661e771258..1962857d57 100755
--- a/basis/random/random.factor
+++ b/basis/random/random.factor
@@ -86,8 +86,6 @@ PRIVATE>
     [ 1.0 swap - log -2.0 * sqrt ]
     bi* * * + ;
 
-USE: vocabs.loader
-
 {
     { [ os windows? ] [ "random.windows" require ] }
     { [ os unix? ] [ "random.unix" require ] }
diff --git a/basis/stack-checker/inlining/inlining.factor b/basis/stack-checker/inlining/inlining.factor
index 23283fb6e3..c99e0f0252 100644
--- a/basis/stack-checker/inlining/inlining.factor
+++ b/basis/stack-checker/inlining/inlining.factor
@@ -2,7 +2,7 @@
 ! See http://factorcode.org/license.txt for BSD license.
 USING: fry namespaces assocs kernel sequences words accessors
 definitions math math.order effects classes arrays combinators
-vectors arrays hints
+vectors hints
 stack-checker.state
 stack-checker.errors
 stack-checker.values
diff --git a/basis/stack-checker/known-words/known-words.factor b/basis/stack-checker/known-words/known-words.factor
index 56ef67d2a8..70382c0829 100644
--- a/basis/stack-checker/known-words/known-words.factor
+++ b/basis/stack-checker/known-words/known-words.factor
@@ -1,7 +1,7 @@
 ! Copyright (C) 2004, 2009 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: fry accessors alien alien.accessors arrays byte-arrays classes
-sequences.private continuations.private effects generic hashtables
+continuations.private effects generic hashtables
 hashtables.private io io.backend io.files io.files.private
 io.streams.c kernel kernel.private math math.private
 math.parser.private memory memory.private namespaces
@@ -11,7 +11,7 @@ strings.private system threads.private classes.tuple
 classes.tuple.private vectors vectors.private words definitions assocs
 summary compiler.units system.private combinators
 combinators.short-circuit locals locals.backend locals.types
-quotations.private combinators.private stack-checker.values
+combinators.private stack-checker.values
 generic.single generic.single.private
 alien.libraries
 stack-checker.alien
diff --git a/basis/stack-checker/transforms/transforms.factor b/basis/stack-checker/transforms/transforms.factor
index 8113a662d6..a85cd44a47 100755
--- a/basis/stack-checker/transforms/transforms.factor
+++ b/basis/stack-checker/transforms/transforms.factor
@@ -3,7 +3,7 @@
 USING: fry accessors arrays kernel kernel.private combinators.private
 words sequences generic math math.order namespaces quotations
 assocs combinators combinators.short-circuit classes.tuple
-classes.tuple.private effects summary hashtables classes generic sets
+classes.tuple.private effects summary hashtables classes sets
 definitions generic.standard slots.private continuations locals
 sequences.private generalizations stack-checker.backend
 stack-checker.state stack-checker.visitor stack-checker.errors
diff --git a/basis/ui/commands/commands.factor b/basis/ui/commands/commands.factor
index 28529b013b..f45c3f8b05 100644
--- a/basis/ui/commands/commands.factor
+++ b/basis/ui/commands/commands.factor
@@ -1,7 +1,7 @@
 ! Copyright (C) 2006, 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors arrays definitions kernel sequences strings
-math assocs words generic namespaces make assocs quotations
+math assocs words generic namespaces make quotations
 splitting ui.gestures unicode.case unicode.categories tr fry ;
 IN: ui.commands
 
diff --git a/basis/ui/gadgets/buttons/buttons.factor b/basis/ui/gadgets/buttons/buttons.factor
index 0504231972..ec11bac2d3 100644
--- a/basis/ui/gadgets/buttons/buttons.factor
+++ b/basis/ui/gadgets/buttons/buttons.factor
@@ -7,6 +7,7 @@ ui.gadgets.borders ui.gadgets.labels ui.gadgets.tracks
 ui.gadgets.packs ui.gadgets.worlds ui.gestures ui.pens ui.pens.solid
 ui.pens.image ui.pens.tile math.rectangles locals fry
 combinators.smart ;
+FROM: models => change-model ;
 IN: ui.gadgets.buttons
 
 TUPLE: button < border pressed? selected? quot ;
diff --git a/basis/ui/gadgets/editors/editors.factor b/basis/ui/gadgets/editors/editors.factor
index 9461b2348f..aa2b9ca58c 100755
--- a/basis/ui/gadgets/editors/editors.factor
+++ b/basis/ui/gadgets/editors/editors.factor
@@ -3,7 +3,7 @@
 USING: accessors arrays documents documents.elements kernel math
 math.ranges models models.arrow namespaces locals fry make opengl
 opengl.gl sequences strings math.vectors math.functions sorting colors
-colors.constants combinators assocs math.order fry calendar alarms
+colors.constants combinators assocs math.order calendar alarms
 continuations ui.clipboards ui.commands ui.gadgets ui.gadgets.borders
 ui.gadgets.buttons ui.gadgets.labels ui.gadgets.scrollers
 ui.gadgets.menus ui.gadgets.wrappers ui.render ui.pens.solid
diff --git a/basis/ui/gadgets/gadgets.factor b/basis/ui/gadgets/gadgets.factor
index 5dd1710cdd..6a289ec1d6 100644
--- a/basis/ui/gadgets/gadgets.factor
+++ b/basis/ui/gadgets/gadgets.factor
@@ -1,6 +1,6 @@
 ! Copyright (C) 2005, 2009 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors arrays hashtables kernel models math namespaces
+USING: accessors arrays hashtables kernel math namespaces
 make sequences quotations math.vectors combinators sorting
 binary-search vectors dlists deques models threads
 concurrency.flags math.order math.rectangles fry locals ;
diff --git a/basis/ui/gadgets/glass/glass.factor b/basis/ui/gadgets/glass/glass.factor
index 945e16150d..d6b87193ca 100644
--- a/basis/ui/gadgets/glass/glass.factor
+++ b/basis/ui/gadgets/glass/glass.factor
@@ -3,6 +3,7 @@
 USING: accessors kernel namespaces ui.gadgets ui.gadgets.worlds
 ui.gadgets.wrappers ui.gestures math.rectangles
 math.rectangles.positioning combinators vectors ;
+FROM: ui.gadgets.wrappers => wrapper ;
 IN: ui.gadgets.glass
 
 GENERIC: hide-glass-hook ( gadget -- )
diff --git a/basis/ui/gadgets/menus/menus.factor b/basis/ui/gadgets/menus/menus.factor
index 734190e7e7..159da59be5 100644
--- a/basis/ui/gadgets/menus/menus.factor
+++ b/basis/ui/gadgets/menus/menus.factor
@@ -3,7 +3,7 @@
 USING: colors.constants kernel locals math.rectangles namespaces
 sequences ui.commands ui.gadgets ui.gadgets.borders ui.gadgets.buttons
 ui.gadgets.glass ui.gadgets.packs ui.gadgets.frames ui.gadgets.worlds
-ui.gadgets.frames ui.gadgets.corners ui.gestures ui.operations
+ui.gadgets.corners ui.gestures ui.operations
 ui.render ui.pens ui.pens.solid opengl math.vectors words accessors
 math math.order sorting ;
 IN: ui.gadgets.menus
diff --git a/basis/ui/gadgets/panes/panes.factor b/basis/ui/gadgets/panes/panes.factor
index 6f6e7ee95f..eb741f13b6 100644
--- a/basis/ui/gadgets/panes/panes.factor
+++ b/basis/ui/gadgets/panes/panes.factor
@@ -11,6 +11,7 @@ ui.gadgets.menus ui.clipboards ui.gestures ui.traverse ui.render
 ui.text ui.gadgets.presentations ui.gadgets.grids ui.gadgets.tracks
 ui.gadgets.icons ui.gadgets.grid-lines ui.baseline-alignment
 colors io.styles ;
+FROM: io.styles => foreground background ;
 IN: ui.gadgets.panes
 
 TUPLE: pane < track
diff --git a/basis/ui/gadgets/tables/tables.factor b/basis/ui/gadgets/tables/tables.factor
index ba3b5a2f78..390e652ac6 100644
--- a/basis/ui/gadgets/tables/tables.factor
+++ b/basis/ui/gadgets/tables/tables.factor
@@ -5,7 +5,7 @@ math.functions math.rectangles math.order math.vectors namespaces
 opengl sequences ui.gadgets ui.gadgets.scrollers ui.gadgets.status-bar
 ui.gadgets.worlds ui.gestures ui.render ui.pens.solid ui.text
 ui.commands ui.images ui.gadgets.menus ui.gadgets.line-support
-math.rectangles models math.ranges sequences combinators
+models math.ranges combinators
 combinators.short-circuit fonts locals strings ;
 IN: ui.gadgets.tables
 
diff --git a/basis/ui/tools/browser/browser.factor b/basis/ui/tools/browser/browser.factor
index 1b8af1dd03..21d827da9b 100644
--- a/basis/ui/tools/browser/browser.factor
+++ b/basis/ui/tools/browser/browser.factor
@@ -1,13 +1,14 @@
 ! Copyright (C) 2006, 2009 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: debugger classes help help.topics help.crossref help.home kernel models
-compiler.units assocs words vocabs accessors fry arrays
-combinators.short-circuit namespaces sequences models help.apropos
+USING: debugger classes help help.topics help.crossref help.home
+kernel models compiler.units assocs words vocabs accessors fry arrays
+combinators.short-circuit namespaces sequences help.apropos
 combinators ui ui.commands ui.gadgets ui.gadgets.panes
 ui.gadgets.scrollers ui.gadgets.tracks ui.gestures ui.gadgets.buttons
 ui.gadgets.packs ui.gadgets.editors ui.gadgets.labels
-ui.gadgets.status-bar ui.gadgets.glass ui.gadgets.borders ui.gadgets.viewports
-ui.tools.common ui.tools.browser.popups ui.tools.browser.history ;
+ui.gadgets.status-bar ui.gadgets.glass ui.gadgets.borders
+ui.gadgets.viewports ui.tools.common ui.tools.browser.popups
+ui.tools.browser.history ;
 IN: ui.tools.browser
 
 TUPLE: browser-gadget < tool history pane scroller search-field popup ;
diff --git a/basis/ui/tools/browser/popups/popups.factor b/basis/ui/tools/browser/popups/popups.factor
index 2cd90ab335..ac4318fa92 100644
--- a/basis/ui/tools/browser/popups/popups.factor
+++ b/basis/ui/tools/browser/popups/popups.factor
@@ -6,6 +6,7 @@ sorting definitions.icons tools.crossref ui.gadgets ui.gadgets.glass
 ui.gadgets.labeled ui.gadgets.scrollers ui.gadgets.tables
 ui.gadgets.search-tables ui.gadgets.wrappers ui.gestures ui.operations
 ui.pens.solid ui.images ;
+FROM: ui.gadgets.wrappers => wrapper ;
 IN: ui.tools.browser.popups
 
 SINGLETON: link-renderer
diff --git a/basis/ui/tools/debugger/debugger-docs.factor b/basis/ui/tools/debugger/debugger-docs.factor
index b68b349774..21a0e95eb4 100644
--- a/basis/ui/tools/debugger/debugger-docs.factor
+++ b/basis/ui/tools/debugger/debugger-docs.factor
@@ -1,5 +1,5 @@
 USING: ui.gadgets help.markup help.syntax kernel quotations
-continuations debugger ui continuations ;
+continuations debugger ui ;
 IN: ui.tools.debugger
 
 HELP: <debugger>
diff --git a/basis/ui/tools/debugger/debugger.factor b/basis/ui/tools/debugger/debugger.factor
index 2c653266e5..cf86ce4223 100755
--- a/basis/ui/tools/debugger/debugger.factor
+++ b/basis/ui/tools/debugger/debugger.factor
@@ -1,7 +1,7 @@
 ! Copyright (C) 2006, 2009 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors arrays hashtables io kernel math models
-colors.constants namespaces sequences sequences words continuations
+colors.constants namespaces sequences words continuations
 debugger prettyprint help editors fonts ui ui.commands ui.gestures
 ui.gadgets ui.pens.solid ui.gadgets.worlds ui.gadgets.packs
 ui.gadgets.buttons ui.gadgets.labels ui.gadgets.panes
diff --git a/basis/ui/tools/deploy/deploy.factor b/basis/ui/tools/deploy/deploy.factor
index d3c1278bf5..cf6f1c066d 100644
--- a/basis/ui/tools/deploy/deploy.factor
+++ b/basis/ui/tools/deploy/deploy.factor
@@ -1,12 +1,11 @@
 ! Copyright (C) 2007, 2009 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: colors kernel namespaces models tools.deploy.config
-tools.deploy.config.editor tools.deploy vocabs
-namespaces models.mapping sequences system accessors fry
-ui.gadgets ui.render ui.gadgets.buttons ui.gadgets.packs
-ui.gadgets.labels ui.gadgets.editors ui.gadgets.borders ui.gestures
-ui.commands assocs ui.gadgets.tracks ui ui.tools.listener
-ui.tools.browser ;
+USING: colors kernel models tools.deploy.config
+tools.deploy.config.editor tools.deploy vocabs namespaces
+models.mapping sequences system accessors fry ui.gadgets ui.render
+ui.gadgets.buttons ui.gadgets.packs ui.gadgets.labels
+ui.gadgets.editors ui.gadgets.borders ui.gestures ui.commands assocs
+ui.gadgets.tracks ui ui.tools.listener ui.tools.browser ;
 IN: ui.tools.deploy
 
 TUPLE: deploy-gadget < pack vocab settings ;
diff --git a/basis/ui/tools/error-list/error-list.factor b/basis/ui/tools/error-list/error-list.factor
index 704ae112e5..e9d4b50bac 100644
--- a/basis/ui/tools/error-list/error-list.factor
+++ b/basis/ui/tools/error-list/error-list.factor
@@ -8,7 +8,7 @@ models.arrow.smart models.search models.mapping debugger
 namespaces summary locals ui ui.commands ui.gadgets ui.gadgets.panes
 ui.gadgets.tables ui.gadgets.labeled ui.gadgets.tracks ui.gestures
 ui.operations ui.tools.browser ui.tools.common ui.gadgets.scrollers
-ui.tools.inspector ui.gadgets.status-bar ui.operations
+ui.tools.inspector ui.gadgets.status-bar
 ui.gadgets.buttons ui.gadgets.borders ui.gadgets.packs
 ui.gadgets.labels ui.baseline-alignment ui.images
 compiler.errors tools.errors tools.errors.model ;
diff --git a/basis/ui/tools/profiler/profiler.factor b/basis/ui/tools/profiler/profiler.factor
index 5fef64ea88..8be357b409 100644
--- a/basis/ui/tools/profiler/profiler.factor
+++ b/basis/ui/tools/profiler/profiler.factor
@@ -6,10 +6,9 @@ vocabs tools.profiler words prettyprint combinators.smart
 definitions.icons see ui ui.commands ui.gadgets ui.gadgets.panes
 ui.gadgets.scrollers ui.gadgets.tracks ui.gestures ui.gadgets.buttons
 ui.gadgets.tables ui.gadgets.search-tables ui.gadgets.labeled
-ui.gadgets.buttons ui.gadgets.packs ui.gadgets.labels
-ui.gadgets.tabbed ui.gadgets.status-bar ui.gadgets.borders
-ui.tools.browser ui.tools.common ui.baseline-alignment
-ui.operations ui.images ;
+ui.gadgets.packs ui.gadgets.labels ui.gadgets.tabbed
+ui.gadgets.status-bar ui.gadgets.borders ui.tools.browser
+ui.tools.common ui.baseline-alignment ui.operations ui.images ;
 FROM: models.arrow => <arrow> ;
 FROM: models.arrow.smart => <smart-arrow> ;
 FROM: models.product => <product> ;
diff --git a/basis/ui/ui.factor b/basis/ui/ui.factor
index b1bfce26e6..144530399c 100644
--- a/basis/ui/ui.factor
+++ b/basis/ui/ui.factor
@@ -1,7 +1,7 @@
 ! Copyright (C) 2006, 2009 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: arrays assocs io kernel math models namespaces make dlists
-deques sequences threads sequences words continuations init
+deques sequences threads words continuations init
 combinators combinators.short-circuit hashtables concurrency.flags
 sets accessors calendar fry destructors ui.gadgets ui.gadgets.private
 ui.gadgets.worlds ui.gadgets.tracks ui.gestures ui.backend ui.render
diff --git a/basis/unix/debugger/debugger.factor b/basis/unix/debugger/debugger.factor
index e059e1a184..4e276373e1 100644
--- a/basis/unix/debugger/debugger.factor
+++ b/basis/unix/debugger/debugger.factor
@@ -1,6 +1,7 @@
 ! Copyright (C) 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: debugger prettyprint accessors unix io kernel ;
+USING: debugger prettyprint accessors unix kernel ;
+FROM: io => write print nl ;
 IN: unix.debugger
 
 M: unix-error error.
diff --git a/basis/unix/process/process.factor b/basis/unix/process/process.factor
index 22757cdbe1..9819e50843 100644
--- a/basis/unix/process/process.factor
+++ b/basis/unix/process/process.factor
@@ -1,5 +1,5 @@
 USING: kernel alien.c-types alien.strings sequences math alien.syntax unix
-vectors kernel namespaces continuations threads assocs vectors
+vectors namespaces continuations threads assocs vectors
 io.backend.unix io.encodings.utf8 unix.utilities fry ;
 IN: unix.process
 
diff --git a/basis/unix/stat/stat.factor b/basis/unix/stat/stat.factor
index 156be96190..c3ab099d38 100644
--- a/basis/unix/stat/stat.factor
+++ b/basis/unix/stat/stat.factor
@@ -15,10 +15,6 @@ CONSTANT: S_IFLNK  OCT: 120000   ! Symbolic link.
 CONSTANT: S_IFSOCK OCT: 140000   ! Socket.
 CONSTANT: S_IFWHT  OCT: 160000   ! Whiteout.
 
-FUNCTION: int chmod ( char* path, mode_t mode ) ;
-FUNCTION: int fchmod ( int fd, mode_t mode ) ;
-FUNCTION: int mkdir ( char* path, mode_t mode ) ;
-
 C-STRUCT: fsid
     { { "int" 2 } "__val" } ;
 
diff --git a/basis/unix/types/types.factor b/basis/unix/types/types.factor
index f7ce6406fe..4ca2c4368a 100644
--- a/basis/unix/types/types.factor
+++ b/basis/unix/types/types.factor
@@ -1,5 +1,4 @@
-USING: kernel system alien.syntax combinators vocabs.loader
-system ;
+USING: kernel system alien.syntax combinators vocabs.loader ;
 IN: unix.types
 
 TYPEDEF: char int8_t
diff --git a/basis/unix/unix.factor b/basis/unix/unix.factor
index 95dca2cb34..9c4251dd1e 100644
--- a/basis/unix/unix.factor
+++ b/basis/unix/unix.factor
@@ -5,7 +5,7 @@ USING: alien alien.c-types alien.syntax kernel libc
 sequences continuations byte-arrays strings math namespaces
 system combinators vocabs.loader accessors
 stack-checker macros locals generalizations unix.types
-io vocabs vocabs.loader ;
+io vocabs ;
 IN: unix
 
 CONSTANT: PROT_NONE   0
@@ -132,6 +132,7 @@ FUNCTION: int ioctl ( int fd, ulong request, char* argp ) ;
 FUNCTION: int lchown ( char* path, uid_t owner, gid_t group ) ;
 FUNCTION: int listen ( int s, int backlog ) ;
 FUNCTION: off_t lseek ( int fildes, off_t offset, int whence ) ;
+FUNCTION: int mkdir ( char* path, mode_t mode ) ;
 FUNCTION: void* mmap ( void* addr, size_t len, int prot, int flags, int fd, off_t offset ) ;
 FUNCTION: int munmap ( void* addr, size_t len ) ;
 FUNCTION: uint ntohl ( uint n ) ;
diff --git a/core/kernel/kernel-docs.factor b/core/kernel/kernel-docs.factor
index 22e0e76451..b617544084 100644
--- a/core/kernel/kernel-docs.factor
+++ b/core/kernel/kernel-docs.factor
@@ -1,6 +1,6 @@
 USING: generic help.markup help.syntax math memory
 namespaces sequences kernel.private layouts classes
-kernel.private vectors combinators quotations strings words
+vectors combinators quotations strings words
 assocs arrays math.order ;
 IN: kernel
 
diff --git a/core/slots/slots-docs.factor b/core/slots/slots-docs.factor
index 1e5f9bf1dd..348e2ec2b2 100644
--- a/core/slots/slots-docs.factor
+++ b/core/slots/slots-docs.factor
@@ -1,8 +1,7 @@
-USING: help.markup help.syntax generic kernel.private parser
-words kernel quotations namespaces sequences words arrays
-effects generic.standard classes.builtin
-slots.private classes strings math assocs byte-arrays alien
-math classes.tuple ;
+USING: help.markup help.syntax generic kernel.private parser words
+kernel quotations namespaces sequences words arrays effects
+generic.standard classes.builtin slots.private classes strings math
+assocs byte-arrays alien classes.tuple ;
 IN: slots
 
 ARTICLE: "accessors" "Slot accessors"

From b31fe9b8f2ff534cd93bf3208f58f1347efb477f Mon Sep 17 00:00:00 2001
From: Slava Pestov <slava@slava-pestovs-macbook-pro.local>
Date: Thu, 14 May 2009 22:31:29 -0500
Subject: [PATCH 05/23] Implement stricter vocab search path semantics, with a
 new API for vocabs.parser. Add map-find-last to sequences vocab

---
 basis/alien/complex/functor/functor.factor    |   2 +-
 basis/alien/syntax/syntax.factor              |   2 +-
 basis/command-line/command-line.factor        |   2 -
 basis/functors/functors.factor                |   4 +-
 basis/help/syntax/syntax.factor               |   2 +-
 basis/io/sockets/sockets.factor               |   2 +-
 basis/listener/listener-tests.factor          |   2 +-
 basis/listener/listener.factor                |   4 +-
 basis/locals/parser/parser.factor             |  14 +-
 basis/opengl/gl/extensions/extensions.factor  |   2 +-
 .../pixel-formats/pixel-formats-docs.factor   |   4 +-
 basis/ui/tools/listener/listener.factor       |  19 +-
 basis/ui/tools/operations/operations.factor   |   4 +-
 core/bootstrap/stage1.factor                  |  14 +-
 core/classes/parser/parser.factor             |   2 +-
 core/init/init.factor                         |   3 +-
 core/io/backend/backend.factor                |   2 +-
 core/parser/parser.factor                     |  22 +-
 core/sbufs/sbufs.factor                       |   2 +-
 core/sequences/sequences.factor               |  15 +-
 core/slots/slots.factor                       |   2 +-
 core/sorting/sorting.factor                   |   6 +-
 core/syntax/syntax.factor                     |  18 +-
 core/vocabs/parser/parser.factor              | 213 +++++++++++++-----
 core/vocabs/vocabs.factor                     |   6 +
 core/words/words.factor                       |   8 +-
 extra/infix/infix.factor                      |   8 +-
 27 files changed, 240 insertions(+), 144 deletions(-)

diff --git a/basis/alien/complex/functor/functor.factor b/basis/alien/complex/functor/functor.factor
index 31af0291b4..fc9e594be5 100644
--- a/basis/alien/complex/functor/functor.factor
+++ b/basis/alien/complex/functor/functor.factor
@@ -23,7 +23,7 @@ WHERE
 : *T ( alien -- z )
     [ T-real ] [ T-imaginary ] bi rect> ; inline
 
-T in get
+T current-vocab
 { { N "real" } { N "imaginary" } }
 define-struct
 
diff --git a/basis/alien/syntax/syntax.factor b/basis/alien/syntax/syntax.factor
index 0cc6d51446..d479e6d498 100644
--- a/basis/alien/syntax/syntax.factor
+++ b/basis/alien/syntax/syntax.factor
@@ -22,7 +22,7 @@ SYNTAX: TYPEDEF:
     scan scan typedef ;
 
 SYNTAX: C-STRUCT:
-    scan in get parse-definition define-struct ;
+    scan current-vocab parse-definition define-struct ;
 
 SYNTAX: C-UNION:
     scan parse-definition define-union ;
diff --git a/basis/command-line/command-line.factor b/basis/command-line/command-line.factor
index f2da4ebdf5..19421359a3 100644
--- a/basis/command-line/command-line.factor
+++ b/basis/command-line/command-line.factor
@@ -69,6 +69,4 @@ SYMBOL: main-vocab-hook
 : ignore-cli-args? ( -- ? )
     os macosx? "run" get "ui" = and ;
 
-: script-mode ( -- ) ;
-
 [ default-cli-args ] "command-line" add-init-hook
diff --git a/basis/functors/functors.factor b/basis/functors/functors.factor
index edd4932c66..e5eb50e82f 100644
--- a/basis/functors/functors.factor
+++ b/basis/functors/functors.factor
@@ -146,10 +146,10 @@ DEFER: ;FUNCTOR delimiter
     } ;
 
 : push-functor-words ( -- )
-    functor-words use get push ;
+    functor-words use-words ;
 
 : pop-functor-words ( -- )
-    functor-words use get delq ;
+    functor-words unuse-words ;
 
 : parse-functor-body ( -- form )
     push-functor-words
diff --git a/basis/help/syntax/syntax.factor b/basis/help/syntax/syntax.factor
index 1844d18d94..af4b9e5e12 100644
--- a/basis/help/syntax/syntax.factor
+++ b/basis/help/syntax/syntax.factor
@@ -16,4 +16,4 @@ SYNTAX: ARTICLE:
     ] dip remember-definition ;
 
 SYNTAX: ABOUT:
-    in get vocab scan-object >>help changed-definition ;
+    current-vocab scan-object >>help changed-definition ;
diff --git a/basis/io/sockets/sockets.factor b/basis/io/sockets/sockets.factor
index d6a8d1b54e..98b9a2ce23 100644
--- a/basis/io/sockets/sockets.factor
+++ b/basis/io/sockets/sockets.factor
@@ -11,7 +11,7 @@ IN: io.sockets
 << {
     { [ os windows? ] [ "windows.winsock" ] }
     { [ os unix? ] [ "unix" ] }
-} cond add-ambiguous-use >>
+} cond use-vocab >>
 
 ! Addressing
 GENERIC: protocol-family ( addrspec -- af )
diff --git a/basis/listener/listener-tests.factor b/basis/listener/listener-tests.factor
index 9ae5250416..ccdd0be8c8 100644
--- a/basis/listener/listener-tests.factor
+++ b/basis/listener/listener-tests.factor
@@ -15,7 +15,7 @@ SYNTAX: hello "Hi" print ;
 ] with-file-vocabs
 
 [
-    "debugger" add-use
+    "debugger" add-ambiguous-use
 
     [ [ \ + 1 2 3 4 ] ]
     [
diff --git a/basis/listener/listener.factor b/basis/listener/listener.factor
index 68777f2f73..4563f61ab7 100644
--- a/basis/listener/listener.factor
+++ b/basis/listener/listener.factor
@@ -10,7 +10,7 @@ IN: listener
 GENERIC: stream-read-quot ( stream -- quot/f )
 
 : parse-lines-interactive ( lines -- quot/f )
-    [ parse-lines in get ] with-compilation-unit in set ;
+    [ parse-lines ] with-compilation-unit ;
 
 : read-quot-step ( lines -- quot/f )
     [ parse-lines-interactive ] [
@@ -98,7 +98,7 @@ t error-summary? set-global
     ] [ drop ] if ;
 
 : prompt. ( -- )
-    in get auto-use? get [ " - auto" append ] when "( " " )" surround
+    current-vocab name>> auto-use? get [ " - auto" append ] when "( " " )" surround
     H{ { background T{ rgba f 1 0.7 0.7 1 } } } format bl flush ;
 
 :: (listener) ( datastack -- )
diff --git a/basis/locals/parser/parser.factor b/basis/locals/parser/parser.factor
index 5e9bdfbed6..8cfe45d1ba 100644
--- a/basis/locals/parser/parser.factor
+++ b/basis/locals/parser/parser.factor
@@ -25,12 +25,6 @@ SYMBOL: in-lambda?
     [ <local-word> [ dup name>> set ] [ ] [ ] tri ] dip
     "local-word-def" set-word-prop ;
 
-: push-locals ( assoc -- )
-    use get push ;
-
-: pop-locals ( assoc -- )
-    use get delq ;
-
 SINGLETON: lambda-parser
 
 SYMBOL: locals
@@ -39,7 +33,9 @@ SYMBOL: locals
     '[
         in-lambda? on
         lambda-parser quotation-parser set
-        [ locals set ] [ push-locals @ ] [ pop-locals ] tri
+        [ locals set ]
+        [ use-words @ ]
+        [ unuse-words ] tri
     ] with-scope ; inline
     
 : (parse-lambda) ( assoc -- quot )
@@ -81,9 +77,9 @@ M: lambda-parser parse-quotation ( -- quotation )
 
 : parse-bindings* ( end -- words assoc )
     [
-        namespace push-locals
+        namespace use-words
         (parse-bindings)
-        namespace pop-locals
+        namespace unuse-words
     ] with-bindings ;
 
 : parse-let* ( -- form )
diff --git a/basis/opengl/gl/extensions/extensions.factor b/basis/opengl/gl/extensions/extensions.factor
index 8878e1904a..9aa4ee429d 100644
--- a/basis/opengl/gl/extensions/extensions.factor
+++ b/basis/opengl/gl/extensions/extensions.factor
@@ -9,7 +9,7 @@ ERROR: unknown-gl-platform ;
     { [ os macosx? ]  [ "opengl.gl.macosx" ] }
     { [ os unix? ] [ "opengl.gl.unix" ] }
     [ unknown-gl-platform ]
-} cond add-use >>
+} cond use-vocab >>
 
 SYMBOL: +gl-function-number-counter+
 SYMBOL: +gl-function-pointers+
diff --git a/basis/ui/pixel-formats/pixel-formats-docs.factor b/basis/ui/pixel-formats/pixel-formats-docs.factor
index 53e44ec18e..b1ab1bc398 100644
--- a/basis/ui/pixel-formats/pixel-formats-docs.factor
+++ b/basis/ui/pixel-formats/pixel-formats-docs.factor
@@ -1,12 +1,12 @@
 USING: destructors help.markup help.syntax kernel math multiline sequences
-vocabs vocabs.parser words ;
+vocabs vocabs.parser words namespaces ;
 IN: ui.pixel-formats
 
 ! break circular dependency
 <<
     "ui.gadgets.worlds" create-vocab drop
     "world" "ui.gadgets.worlds" create drop
-    "ui.gadgets.worlds" (add-use)
+    "ui.gadgets.worlds" vocab-words use-words
 >>
 
 ARTICLE: "ui.pixel-formats-attributes" "Pixel format attributes"
diff --git a/basis/ui/tools/listener/listener.factor b/basis/ui/tools/listener/listener.factor
index 6ed3577a06..19328b0b31 100644
--- a/basis/ui/tools/listener/listener.factor
+++ b/basis/ui/tools/listener/listener.factor
@@ -38,13 +38,12 @@ output history flag mailbox thread waiting token-model word-model popup ;
         [ thread>> dup [ thread-registered? ] when ]
     } 1&& not ;
 
-SLOT: vocabs
+SLOT: manifest
 
-M: interactor vocabs>>
+M: interactor manifest>>
     dup interactor-busy? [ drop f ] [
-        use swap
         interactor-continuation name>>
-        assoc-stack
+        manifest swap assoc-stack
     ] if ;
 
 : vocab-exists? ( name -- ? )
@@ -56,7 +55,7 @@ M: vocab-completion (word-at-caret)
     drop dup vocab-exists? [ >vocab-link ] [ drop f ] if ;
 
 M: word-completion (word-at-caret)
-    vocabs>> assoc-stack ;
+    manifest>> search-manifest ;
 
 M: char-completion (word-at-caret)
     2drop f ;
@@ -300,15 +299,15 @@ M: listener-operation invoke-command ( target command -- )
 : clear-stack ( listener -- )
     [ [ clear ] \ clear ] dip (call-listener) ;
 
-: use-if-necessary ( word seq -- )
+: use-if-necessary ( word manifest -- )
     2dup [ vocabulary>> ] dip and [
-        2dup [ assoc-stack ] keep = [ 2drop ] [
-            [ vocabulary>> vocab-words ] dip push
-        ] if
+        manifest [
+            vocabulary>> use-vocab
+        ] with-variable
     ] [ 2drop ] if ;
 
 M: word accept-completion-hook
-    interactor>> vocabs>> use-if-necessary ;
+    interactor>> manifest>> use-if-necessary ;
 
 M: object accept-completion-hook 2drop ;
 
diff --git a/basis/ui/tools/operations/operations.factor b/basis/ui/tools/operations/operations.factor
index 49bb74d18c..4944cba1d6 100644
--- a/basis/ui/tools/operations/operations.factor
+++ b/basis/ui/tools/operations/operations.factor
@@ -131,13 +131,13 @@ M: quotation com-stack-effect infer. ;
 
 M: word com-stack-effect 1quotation com-stack-effect ;
 
-: com-enter-in ( vocab -- ) vocab-name set-in ;
+: com-enter-in ( vocab -- ) vocab-name set-current-vocab ;
 
 [ vocab? ] \ com-enter-in H{
     { +listener+ t }
 } define-operation
 
-: com-use-vocab ( vocab -- ) vocab-name add-use ;
+: com-use-vocab ( vocab -- ) vocab-name use-vocab ;
 
 [ vocab-spec? ] \ com-use-vocab H{
     { +secondary+ t }
diff --git a/core/bootstrap/stage1.factor b/core/bootstrap/stage1.factor
index 1da2dfee59..088a8a6320 100644
--- a/core/bootstrap/stage1.factor
+++ b/core/bootstrap/stage1.factor
@@ -1,10 +1,10 @@
-! Copyright (C) 2004, 2008 Slava Pestov.
+! Copyright (C) 2004, 2009 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: arrays debugger generic hashtables io assocs
-kernel.private kernel math memory namespaces make parser
-prettyprint sequences vectors words system splitting
-init io.files bootstrap.image bootstrap.image.private vocabs
-vocabs.loader system debugger continuations ;
+USING: arrays debugger generic hashtables io assocs kernel.private
+kernel math memory namespaces make parser prettyprint sequences
+vectors words system splitting init io.files vocabs vocabs.loader
+debugger continuations ;
+QUALIFIED: bootstrap.image.private
 IN: bootstrap.stage1
 
 "Bootstrap stage 1..." print flush
@@ -51,4 +51,4 @@ load-help? off
         ] if
     ] %
 ] [ ] make
-bootstrap-boot-quot set
+bootstrap.image.private:bootstrap-boot-quot set
diff --git a/core/classes/parser/parser.factor b/core/classes/parser/parser.factor
index 17a7b23552..bd2e6ea4a0 100644
--- a/core/classes/parser/parser.factor
+++ b/core/classes/parser/parser.factor
@@ -1,6 +1,6 @@
 ! Copyright (C) 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: parser words kernel classes compiler.units lexer ;
+USING: parser vocabs.parser words kernel classes compiler.units lexer ;
 IN: classes.parser
 
 : save-class-location ( class -- )
diff --git a/core/init/init.factor b/core/init/init.factor
index 0140fcc0e8..5d8e88b85f 100644
--- a/core/init/init.factor
+++ b/core/init/init.factor
@@ -1,8 +1,7 @@
 ! Copyright (C) 2004, 2009 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: continuations continuations.private kernel
-kernel.private sequences assocs namespaces namespaces.private
-continuations continuations.private ;
+kernel.private sequences assocs namespaces namespaces.private ;
 IN: init
 
 SYMBOL: init-hooks
diff --git a/core/io/backend/backend.factor b/core/io/backend/backend.factor
index ac3fbef8d0..84d1f52b9c 100644
--- a/core/io/backend/backend.factor
+++ b/core/io/backend/backend.factor
@@ -1,7 +1,7 @@
 ! Copyright (C) 2007, 2009 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: init kernel system namespaces io io.encodings
-io.encodings.utf8 init assocs splitting alien ;
+io.encodings.utf8 assocs splitting alien ;
 IN: io.backend
 
 SYMBOL: io-backend
diff --git a/core/parser/parser.factor b/core/parser/parser.factor
index d802fd72fa..31b5286c18 100644
--- a/core/parser/parser.factor
+++ b/core/parser/parser.factor
@@ -31,16 +31,6 @@ t parser-notes set-global
 
 M: parsing-word stack-effect drop (( parsed -- parsed )) ;
 
-TUPLE: no-current-vocab ;
-
-: no-current-vocab ( -- vocab )
-    \ no-current-vocab boa
-    { { "Define words in scratchpad vocabulary" "scratchpad" } }
-    throw-restarts dup set-in ;
-
-: current-vocab ( -- str )
-    in get [ no-current-vocab ] unless* ;
-
 : create-in ( str -- word )
     current-vocab create dup set-word dup save-location ;
 
@@ -55,7 +45,7 @@ SYMBOL: auto-use?
 : no-word-restarted ( restart-value -- word )
     dup word? [
         dup vocabulary>>
-        [ (add-use) ]
+        [ use-vocab ]
         [ amended-use get dup [ push ] [ 2drop ] if ]
         [ "Added \"" "\" vocabulary to search path" surround note. ]
         tri
@@ -134,8 +124,9 @@ SYMBOL: bootstrap-syntax
 
 : with-file-vocabs ( quot -- )
     [
-        f in set { "syntax" } set-use
-        bootstrap-syntax get [ use get push ] when*
+        <manifest> manifest set
+        "syntax" use-vocab
+        bootstrap-syntax get [ use-words ] when*
         call
     ] with-scope ; inline
 
@@ -195,8 +186,9 @@ SYMBOL: interactive-vocabs
 
 : with-interactive-vocabs ( quot -- )
     [
-        "scratchpad" in set
-        interactive-vocabs get set-use
+        <manifest> manifest set
+        "scratchpad" set-current-vocab
+        interactive-vocabs get only-use-vocabs
         call
     ] with-scope ; inline
 
diff --git a/core/sbufs/sbufs.factor b/core/sbufs/sbufs.factor
index 5590432ef4..0b2c170c1e 100644
--- a/core/sbufs/sbufs.factor
+++ b/core/sbufs/sbufs.factor
@@ -1,6 +1,6 @@
 ! Copyright (C) 2004, 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors kernel math strings sequences.private sequences
+USING: accessors kernel math sequences.private sequences
 strings growable strings.private ;
 IN: sbufs
 
diff --git a/core/sequences/sequences.factor b/core/sequences/sequences.factor
index dd48501fa0..99dddb8aed 100755
--- a/core/sequences/sequences.factor
+++ b/core/sequences/sequences.factor
@@ -834,11 +834,20 @@ PRIVATE>
     [ [ 2unclip-slice ] dip [ call ] keep ] dip
     compose 2reduce ; inline
 
-: map-find ( seq quot -- result elt )
-    [ f ] 2dip
-    [ [ nip ] dip call dup ] curry find
+<PRIVATE
+
+: (map-find) ( seq quot find-quot -- result elt )
+    [ [ f ] 2dip [ [ nip ] dip call dup ] curry ] dip call
     [ [ drop f ] unless ] dip ; inline
 
+PRIVATE>
+
+: map-find ( seq quot -- result elt )
+    [ find ] (map-find) ; inline
+
+: map-find-last ( seq quot -- result elt )
+    [ find-last ] (map-find) ; inline
+
 : unclip-last-slice ( seq -- butlast-slice last )
     [ but-last-slice ] [ peek ] bi ; inline
 
diff --git a/core/slots/slots.factor b/core/slots/slots.factor
index 6bb854daf6..304ded0adb 100755
--- a/core/slots/slots.factor
+++ b/core/slots/slots.factor
@@ -1,7 +1,7 @@
 ! Copyright (C) 2005, 2009 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: arrays byte-arrays kernel kernel.private math namespaces
-make sequences strings words effects generic generic.standard
+make sequences strings effects generic generic.standard
 classes classes.algebra slots.private combinators accessors
 words sequences.private assocs alien quotations hashtables ;
 IN: slots
diff --git a/core/sorting/sorting.factor b/core/sorting/sorting.factor
index f2fa6b8771..0c0951bbce 100644
--- a/core/sorting/sorting.factor
+++ b/core/sorting/sorting.factor
@@ -1,7 +1,7 @@
-! Copyright (C) 2005, 2008 Slava Pestov.
+! Copyright (C) 2005, 2009 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors arrays kernel math sequences vectors math.order
-sequences sequences.private math.order ;
+USING: accessors arrays kernel math vectors math.order
+sequences sequences.private ;
 IN: sorting
 
 ! Optimized merge-sort:
diff --git a/core/syntax/syntax.factor b/core/syntax/syntax.factor
index 8d52a2c786..b29c20850b 100644
--- a/core/syntax/syntax.factor
+++ b/core/syntax/syntax.factor
@@ -41,28 +41,26 @@ IN: bootstrap.syntax
 
     "#!" [ POSTPONE: ! ] define-core-syntax
 
-    "IN:" [ scan set-in ] define-core-syntax
+    "IN:" [ scan set-current-vocab ] define-core-syntax
 
-    "PRIVATE>" [ in get ".private" ?tail drop set-in ] define-core-syntax
+    "<PRIVATE" [ begin-private ] define-core-syntax
 
-    "<PRIVATE" [
-        POSTPONE: PRIVATE> in get ".private" append set-in
-    ] define-core-syntax
+    "PRIVATE>" [ end-private ] define-core-syntax
 
-    "USE:" [ scan add-use ] define-core-syntax
+    "USE:" [ scan use-vocab ] define-core-syntax
 
-    "USING:" [ ";" parse-tokens [ add-use ] each ] define-core-syntax
+    "USING:" [ ";" parse-tokens [ use-vocab ] each ] define-core-syntax
 
     "QUALIFIED:" [ scan dup add-qualified ] define-core-syntax
 
     "QUALIFIED-WITH:" [ scan scan add-qualified ] define-core-syntax
 
     "FROM:" [
-        scan "=>" expect ";" parse-tokens swap add-words-from
+        scan "=>" expect ";" parse-tokens add-words-from
     ] define-core-syntax
 
     "EXCLUDE:" [
-        scan "=>" expect ";" parse-tokens swap add-words-excluding
+        scan "=>" expect ";" parse-tokens add-words-excluding
     ] define-core-syntax
 
     "RENAME:" [
@@ -227,7 +225,7 @@ IN: bootstrap.syntax
         "))" parse-effect parsed
     ] define-core-syntax
 
-    "MAIN:" [ scan-word in get vocab (>>main) ] define-core-syntax
+    "MAIN:" [ scan-word current-vocab (>>main) ] define-core-syntax
 
     "<<" [
         [
diff --git a/core/vocabs/parser/parser.factor b/core/vocabs/parser/parser.factor
index d5978270dc..426894794e 100644
--- a/core/vocabs/parser/parser.factor
+++ b/core/vocabs/parser/parser.factor
@@ -2,11 +2,167 @@
 ! Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: assocs hashtables kernel namespaces sequences
-sets strings vocabs sorting accessors arrays compiler.units ;
+sets strings vocabs sorting accessors arrays compiler.units
+combinators vectors splitting continuations ;
 IN: vocabs.parser
 
 ERROR: no-word-error name ;
 
+TUPLE: manifest
+current-vocab
+{ search-vocabs vector }
+{ qualified-vocabs vector }
+{ extra-words vector } ;
+
+: <manifest> ( -- manifest )
+    manifest new
+        V{ } clone >>search-vocabs
+        V{ } clone >>qualified-vocabs
+        V{ } clone >>extra-words ;
+
+M: manifest clone
+    call-next-method
+        [ clone ] change-search-vocabs
+        [ clone ] change-qualified-vocabs
+        [ clone ] change-extra-words ;
+
+<PRIVATE
+
+: clear-manifest ( -- )
+    manifest get
+    [ search-vocabs>> delete-all ]
+    [ qualified-vocabs>> delete-all ]
+    [ extra-words>> delete-all ]
+    tri ;
+
+: (use-vocab) ( vocab -- vocab seq )
+    load-vocab manifest get search-vocabs>> ;
+
+: (add-qualified) ( qualified -- )
+    manifest get qualified-vocabs>> push ;
+
+: (from) ( vocab words -- vocab words words' assoc )
+    2dup swap load-vocab words>> ;
+
+: (use-words) ( assoc -- assoc seq )
+    manifest get extra-words>> ;
+
+: extract-words ( seq assoc -- assoc' )
+    extract-keys dup [ [ drop ] [ no-word-error ] if ] assoc-each ;
+
+: (lookup) ( name assoc -- word/f )
+    at dup forward-reference? [ drop f ] when ;
+
+PRIVATE>
+
+: set-current-vocab ( name -- )
+    create-vocab manifest get
+    [ (>>current-vocab) ]
+    [ [ words>> ] dip extra-words>> push ]
+    2bi ; 
+
+TUPLE: no-current-vocab ;
+
+: no-current-vocab ( -- vocab )
+    \ no-current-vocab boa
+    { { "Define words in scratchpad vocabulary" "scratchpad" } }
+    throw-restarts dup set-current-vocab ;
+
+: current-vocab ( -- vocab )
+    manifest get current-vocab>> [ no-current-vocab ] unless* ;
+
+: begin-private ( -- )
+    manifest get current-vocab>> vocab-name ".private" ?tail
+    [ drop ] [ ".private" append set-current-vocab ] if ;
+
+: end-private ( -- )
+    manifest get current-vocab>> vocab-name ".private" ?tail
+    [ set-current-vocab ] [ drop ] if ;
+
+: use-vocab ( vocab -- ) (use-vocab) push ;
+
+: unuse-vocab ( vocab -- ) (use-vocab) delq ;
+
+: only-use-vocabs ( vocabs -- )
+    clear-manifest
+    [ vocab ] V{ } map-as sift
+    manifest get search-vocabs>> push-all ;
+
+TUPLE: qualified vocab prefix words ;
+
+: <qualified> ( vocab prefix -- qualified )
+    2dup
+    [ load-vocab words>> ] [ CHAR: : suffix ] bi*
+    [ swap [ prepend ] dip ] curry assoc-map
+    qualified boa ;
+
+: add-qualified ( vocab prefix -- )
+    <qualified> (add-qualified) ;
+
+TUPLE: from vocab names words ;
+
+: <from> ( vocab words -- from )
+    (from) extract-words from boa ;
+
+: add-words-from ( vocab words -- )
+    <from> (add-qualified) ;
+
+TUPLE: exclude vocab names words ;
+
+: <exclude> ( vocab words -- from )
+    (from) [ nip ] [ extract-words ] 2bi assoc-diff exclude boa ;
+
+: add-words-excluding ( vocab words -- )
+    <exclude> (add-qualified) ;
+
+TUPLE: rename word vocab words ;
+
+: <rename> ( word vocab new-name -- rename )
+    [ 2dup load-vocab words>> dupd at [ ] [ no-word-error ] ?if ] dip
+    associate rename boa ;
+
+: add-renamed-word ( word vocab new-name -- )
+    <rename> (add-qualified) ;
+
+: use-words ( words -- ) (use-words) push ;
+
+: unuse-words ( words -- ) (use-words) delq ;
+
+ERROR: ambiguous-use-error words ;
+
+<PRIVATE
+
+: (vocab-search) ( name assocs -- words n )
+    [ words>> (lookup) ] with map
+    sift dup length ;
+
+: vocab-search ( name manifest -- word/f )
+    search-vocabs>>
+    (vocab-search) {
+        { 0 [ drop f ] }
+        { 1 [ first ] }
+        [ drop ambiguous-use-error ]
+    } case ;
+
+: qualified-search ( name manifest -- word/f )
+    qualified-vocabs>>
+    (vocab-search) 0 = [ drop f ] [ peek ] if ;
+
+: word-search ( name manifest -- word/f )
+    extra-words>> [ (lookup) ] with map-find-last drop ;
+
+PRIVATE>
+
+: search-manifest ( name manifest -- word/f )
+    2dup word-search dup [ 2nip ] [
+        drop 2dup qualified-search dup [ 2nip ] [
+            drop vocab-search
+        ] if
+    ] if ;
+
+: search ( name -- word/f )
+    manifest get search-manifest ;
+
 : word-restarts ( name possibilities -- restarts )
     natural-sort
     [ [ vocabulary>> "Use the " " vocabulary" surround ] keep ] { } map>assoc
@@ -15,58 +171,3 @@ ERROR: no-word-error name ;
 
 : <no-word-error> ( name possibilities -- error restarts )
     [ drop \ no-word-error boa ] [ word-restarts ] 2bi ;
-
-SYMBOL: use
-SYMBOL: in
-
-: (add-use) ( vocab -- )
-    vocab-words use get push ;
-
-: add-use ( vocab -- )
-    load-vocab (add-use) ;
-
-: set-use ( seq -- )
-    [ vocab-words ] V{ } map-as sift use set ;
-
-: add-qualified ( vocab prefix -- )
-    [ load-vocab vocab-words ] [ CHAR: : suffix ] bi*
-    [ swap [ prepend ] dip ] curry assoc-map
-    use get push ;
-
-: words-named-in ( words assoc -- assoc' )
-    [ dupd at [ no-word-error ] unless* ] curry { } map>assoc ;
-
-: partial-vocab-including ( words vocab -- assoc )
-    load-vocab vocab-words words-named-in ;
-
-: add-words-from ( words vocab -- )
-    partial-vocab-including use get push ;
-
-: partial-vocab-excluding ( words vocab -- assoc )
-    load-vocab vocab-words [ nip ] [ words-named-in ] 2bi assoc-diff ;
-
-: add-words-excluding ( words vocab -- )
-    partial-vocab-excluding use get push ;
-
-: add-renamed-word ( word vocab new-name -- )
-    [ load-vocab vocab-words dupd at [ ] [ no-word-error ] ?if ] dip
-    associate use get push ;
-
-: check-vocab-string ( name -- name )
-    dup string? [ "Vocabulary name must be a string" throw ] unless ;
-
-: set-in ( name -- )
-    check-vocab-string dup in set create-vocab (add-use) ;
-
-: check-forward ( str word -- word/f )
-    dup forward-reference? [
-        drop
-        use get
-        [ at ] with map sift
-        [ forward-reference? not ] find-last nip
-    ] [
-        nip
-    ] if ;
-
-: search ( str -- word/f )
-    dup use get assoc-stack check-forward ;
\ No newline at end of file
diff --git a/core/vocabs/vocabs.factor b/core/vocabs/vocabs.factor
index 6c12b7b325..914f1cd601 100644
--- a/core/vocabs/vocabs.factor
+++ b/core/vocabs/vocabs.factor
@@ -78,7 +78,13 @@ GENERIC: vocabs-changed ( obj -- )
 : notify-vocab-observers ( -- )
     vocab-observers get [ vocabs-changed ] each ;
 
+ERROR: bad-vocab-name name ;
+
+: check-vocab-name ( name -- name )
+    dup string? [ bad-vocab-name ] unless ;
+
 : create-vocab ( name -- vocab )
+    check-vocab-name
     dictionary get [ <vocab> ] cache
     notify-vocab-observers ;
 
diff --git a/core/words/words.factor b/core/words/words.factor
index c01cf13bcd..2ebdb8b7a8 100755
--- a/core/words/words.factor
+++ b/core/words/words.factor
@@ -1,7 +1,7 @@
 ! Copyright (C) 2004, 2009 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors arrays definitions graphs assocs kernel
-kernel.private kernel.private slots.private math namespaces sequences
+USING: accessors arrays definitions graphs kernel
+kernel.private slots.private math namespaces sequences
 strings vectors sbufs quotations assocs hashtables sorting vocabs
 math.order sets ;
 IN: words
@@ -180,12 +180,12 @@ M: word reset-word
 ERROR: bad-create name vocab ;
 
 : check-create ( name vocab -- name vocab )
-    2dup [ string? ] both?
+    2dup [ string? ] [ [ string? ] [ vocab? ] bi or ] bi* and
     [ bad-create ] unless ;
 
 : create ( name vocab -- word )
     check-create 2dup lookup
-    dup [ 2nip ] [ drop <word> dup reveal ] if ;
+    dup [ 2nip ] [ drop vocab-name <word> dup reveal ] if ;
 
 : constructor-word ( name vocab -- word )
     [ "<" ">" surround ] dip create ;
diff --git a/extra/infix/infix.factor b/extra/infix/infix.factor
index 5597422898..09f1b0e4b1 100644
--- a/extra/infix/infix.factor
+++ b/extra/infix/infix.factor
@@ -85,12 +85,10 @@ SYNTAX: [infix
     "infix]" [infix-parse parsed \ call parsed ;
 
 <PRIVATE
+
 : parse-infix-locals ( assoc end -- quot )
-    [
-        in-lambda? on
-        [ dup [ locals set ] [ push-locals ] bi ] dip
-        [infix-parse prepare-operand swap pop-locals
-    ] with-scope ;
+    '[ _ [infix-parse prepare-operand ] ((parse-lambda)) ;
+
 PRIVATE>
 
 SYNTAX: [infix|

From b62630b5ac8c8b99883b467db92bceadf13e480b Mon Sep 17 00:00:00 2001
From: Slava Pestov <slava@slava-pestovs-macbook-pro.local>
Date: Thu, 14 May 2009 23:23:06 -0500
Subject: [PATCH 06/23] Updating code in basis and extra for stricter vocab
 search path semantics

---
 basis/alien/fortran/fortran.factor                 |  2 +-
 basis/channels/channels.factor                     |  2 +-
 basis/checksums/sha1/sha1.factor                   |  2 +-
 basis/db/errors/postgresql/postgresql.factor       |  3 ++-
 basis/db/tester/tester.factor                      |  2 +-
 basis/db/tuples/tuples.factor                      |  2 +-
 basis/formatting/formatting.factor                 |  8 ++++----
 basis/furnace/sessions/sessions-docs.factor        |  2 +-
 basis/game-input/iokit/iokit.factor                |  2 +-
 basis/help/html/html.factor                        |  2 +-
 basis/html/templates/chloe/chloe-docs.factor       |  3 ++-
 basis/html/templates/chloe/chloe.factor            |  4 ++--
 basis/html/templates/chloe/syntax/syntax.factor    | 12 +++++-------
 basis/html/templates/fhtml/fhtml.factor            |  2 +-
 basis/http/server/server.factor                    |  4 +---
 basis/inverse/inverse.factor                       |  2 +-
 basis/io/encodings/gb18030/gb18030.factor          |  5 +++--
 basis/io/mmap/mmap.factor                          |  2 +-
 basis/locals/locals-tests.factor                   |  8 --------
 basis/peg/ebnf/ebnf.factor                         |  2 +-
 basis/random/dummy/dummy.factor                    |  2 +-
 basis/regexp/classes/classes.factor                |  3 ++-
 basis/soundex/soundex.factor                       |  2 +-
 basis/tools/files/unix/unix.factor                 |  2 +-
 .../ui/tools/listener/completion/completion.factor |  8 ++++----
 basis/ui/tools/listener/listener.factor            |  2 +-
 basis/unicode/collation/collation.factor           | 11 +++++------
 basis/xml/syntax/syntax.factor                     |  4 ++--
 basis/xmode/code2html/code2html.factor             |  6 +++---
 basis/xmode/marker/marker.factor                   |  3 +--
 extra/4DNav/turtle/turtle.factor                   |  9 +++------
 extra/4DNav/window3D/window3D.factor               |  1 -
 extra/benchmark/backtrack/backtrack.factor         |  2 +-
 extra/bunny/outlined/outlined.factor               |  1 +
 extra/fjsc/fjsc.factor                             |  3 +--
 extra/fuel/eval/eval.factor                        | 14 +++++++-------
 extra/fuel/xref/xref.factor                        |  6 +++++-
 extra/google-tech-talk/google-tech-talk.factor     |  2 +-
 extra/hashcash/hashcash.factor                     |  7 +++----
 extra/html/parser/analyzer/analyzer.factor         |  2 +-
 extra/id3/id3.factor                               |  2 +-
 extra/infix/infix.factor                           |  2 +-
 extra/jamshred/tunnel/tunnel.factor                |  1 +
 extra/koszul/koszul.factor                         |  2 +-
 extra/mason/common/common.factor                   |  2 +-
 extra/mason/mason.factor                           |  5 +++--
 extra/mason/release/release.factor                 |  2 +-
 extra/mongodb/benchmark/benchmark.factor           |  4 ++--
 extra/mongodb/tuple/tuple.factor                   |  2 ++
 extra/otug-talk/otug-talk.factor                   |  2 +-
 extra/peg/javascript/parser/parser.factor          |  3 ++-
 extra/project-euler/common/common.factor           |  2 +-
 extra/spheres/spheres.factor                       |  1 +
 extra/tetris/tetris.factor                         |  1 +
 extra/ui/gadgets/book-extras/book-extras.factor    |  1 +
 extra/vpri-talk/vpri-talk.factor                   |  2 +-
 extra/webapps/site-watcher/site-watcher.factor     |  2 +-
 extra/webapps/wiki/wiki.factor                     |  2 +-
 {extra => unmaintained}/sandbox/authors.txt        |  0
 .../sandbox/sandbox-tests.factor                   |  0
 {extra => unmaintained}/sandbox/sandbox.factor     |  0
 {extra => unmaintained}/sandbox/summary.txt        |  0
 .../sandbox/syntax/syntax.factor                   |  0
 63 files changed, 98 insertions(+), 101 deletions(-)
 rename {extra => unmaintained}/sandbox/authors.txt (100%)
 rename {extra => unmaintained}/sandbox/sandbox-tests.factor (100%)
 rename {extra => unmaintained}/sandbox/sandbox.factor (100%)
 rename {extra => unmaintained}/sandbox/summary.txt (100%)
 rename {extra => unmaintained}/sandbox/syntax/syntax.factor (100%)

diff --git a/basis/alien/fortran/fortran.factor b/basis/alien/fortran/fortran.factor
index b27c62b9a1..54b799f675 100644
--- a/basis/alien/fortran/fortran.factor
+++ b/basis/alien/fortran/fortran.factor
@@ -421,7 +421,7 @@ PRIVATE>
 : define-fortran-record ( name vocab fields -- )
     [ >lower ] [ ] [ fortran-record>c-struct ] tri* define-struct ;
 
-SYNTAX: RECORD: scan in get parse-definition define-fortran-record ;
+SYNTAX: RECORD: scan current-vocab parse-definition define-fortran-record ;
 
 : set-fortran-abi ( library -- )
     library-fortran-abis get-global at fortran-abi set ;
diff --git a/basis/channels/channels.factor b/basis/channels/channels.factor
index 9b8c418634..0eb7881f95 100644
--- a/basis/channels/channels.factor
+++ b/basis/channels/channels.factor
@@ -3,7 +3,7 @@
 !
 ! Channels - based on ideas from newsqueak
 USING: kernel sequences threads continuations
-random math accessors random ;
+random math accessors ;
 IN: channels
 
 TUPLE: channel receivers senders ;
diff --git a/basis/checksums/sha1/sha1.factor b/basis/checksums/sha1/sha1.factor
index e7aee0dd09..707aa66ba6 100644
--- a/basis/checksums/sha1/sha1.factor
+++ b/basis/checksums/sha1/sha1.factor
@@ -1,7 +1,7 @@
 ! Copyright (C) 2006, 2008 Doug Coleman.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: arrays combinators kernel io io.encodings.binary io.files
-io.streams.byte-array math.vectors strings sequences namespaces
+io.streams.byte-array math.vectors strings namespaces
 make math parser sequences assocs grouping vectors io.binary
 hashtables math.bitwise checksums checksums.common
 checksums.stream ;
diff --git a/basis/db/errors/postgresql/postgresql.factor b/basis/db/errors/postgresql/postgresql.factor
index 02b43ecd88..3cd0909288 100644
--- a/basis/db/errors/postgresql/postgresql.factor
+++ b/basis/db/errors/postgresql/postgresql.factor
@@ -1,7 +1,8 @@
 ! Copyright (C) 2009 Doug Coleman.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: kernel db.errors peg.ebnf strings sequences math
-combinators.short-circuit accessors math.parser quoting ;
+combinators.short-circuit accessors math.parser quoting
+locals ;
 IN: db.errors.postgresql
 
 EBNF: parse-postgresql-sql-error
diff --git a/basis/db/tester/tester.factor b/basis/db/tester/tester.factor
index 56bac7efcd..19140259bf 100644
--- a/basis/db/tester/tester.factor
+++ b/basis/db/tester/tester.factor
@@ -2,7 +2,7 @@
 ! See http://factorcode.org/license.txt for BSD license.
 USING: concurrency.combinators db.pools db.sqlite db.tuples
 db.types kernel math random threads tools.test db sequences
-io prettyprint db.postgresql db.sqlite accessors io.files.temp
+io prettyprint db.postgresql accessors io.files.temp
 namespaces fry system math.parser ;
 IN: db.tester
 
diff --git a/basis/db/tuples/tuples.factor b/basis/db/tuples/tuples.factor
index 19d4be5fc8..388c9ba47e 100644
--- a/basis/db/tuples/tuples.factor
+++ b/basis/db/tuples/tuples.factor
@@ -2,7 +2,7 @@
 ! See http://factorcode.org/license.txt for BSD license.
 USING: arrays assocs classes db kernel namespaces
 classes.tuple words sequences slots math accessors
-math.parser io prettyprint db.types continuations
+math.parser io prettyprint continuations
 destructors mirrors sets db.types db.private fry
 combinators.short-circuit db.errors ;
 IN: db.tuples
diff --git a/basis/formatting/formatting.factor b/basis/formatting/formatting.factor
index 5a517e4ac4..f8b9ba501b 100644
--- a/basis/formatting/formatting.factor
+++ b/basis/formatting/formatting.factor
@@ -1,10 +1,10 @@
 ! Copyright (C) 2008 John Benediktsson
 ! See http://factorcode.org/license.txt for BSD license
 
-USING: accessors arrays ascii assocs calendar combinators fry kernel 
-generalizations io io.encodings.ascii io.files io.streams.string
-macros math math.functions math.parser peg.ebnf quotations
-sequences splitting strings unicode.case vectors combinators.smart ;
+USING: accessors arrays assocs calendar combinators fry kernel
+generalizations io io.streams.string macros math math.functions
+math.parser peg.ebnf quotations sequences splitting strings
+unicode.categories unicode.case vectors combinators.smart ;
 
 IN: formatting
 
diff --git a/basis/furnace/sessions/sessions-docs.factor b/basis/furnace/sessions/sessions-docs.factor
index 7a4de18eaf..5c1ceecbf0 100644
--- a/basis/furnace/sessions/sessions-docs.factor
+++ b/basis/furnace/sessions/sessions-docs.factor
@@ -1,5 +1,5 @@
 USING: help.markup help.syntax io.streams.string quotations
-strings calendar serialize kernel furnace.db words words.symbol
+strings calendar serialize furnace.db words words.symbol
 kernel ;
 IN: furnace.sessions
 
diff --git a/basis/game-input/iokit/iokit.factor b/basis/game-input/iokit/iokit.factor
index 5f09a054f9..c42d48d569 100755
--- a/basis/game-input/iokit/iokit.factor
+++ b/basis/game-input/iokit/iokit.factor
@@ -1,7 +1,7 @@
 USING: cocoa cocoa.plists core-foundation iokit iokit.hid
 kernel cocoa.enumeration destructors math.parser cocoa.application 
 sequences locals combinators.short-circuit threads
-namespaces assocs vectors arrays combinators hints alien
+namespaces assocs arrays combinators hints alien
 core-foundation.run-loop accessors sequences.private
 alien.c-types math parser game-input vectors ;
 IN: game-input.iokit
diff --git a/basis/help/html/html.factor b/basis/help/html/html.factor
index 348fcbbbfb..09208749b9 100644
--- a/basis/help/html/html.factor
+++ b/basis/help/html/html.factor
@@ -4,7 +4,7 @@ USING: io.encodings.utf8 io.encodings.ascii io.encodings.binary
 io.files io.files.temp io.directories html.streams help kernel
 assocs sequences make words accessors arrays help.topics vocabs
 vocabs.hierarchy help.vocabs namespaces prettyprint io
-vocabs.loader serialize fry memoize ascii unicode.case math.order
+vocabs.loader serialize fry memoize unicode.case math.order
 sorting debugger html xml.syntax xml.writer math.parser ;
 IN: help.html
 
diff --git a/basis/html/templates/chloe/chloe-docs.factor b/basis/html/templates/chloe/chloe-docs.factor
index fcfd454478..9716407de8 100644
--- a/basis/html/templates/chloe/chloe-docs.factor
+++ b/basis/html/templates/chloe/chloe-docs.factor
@@ -1,8 +1,9 @@
 IN: html.templates.chloe
-USING: xml.data help.markup help.syntax html.components html.forms
+USING: help.markup help.syntax html.components html.forms
 html.templates html.templates.chloe.syntax
 html.templates.chloe.compiler html.templates.chloe.components
 math strings quotations namespaces ;
+FROM: xml.data => tag ;
 
 HELP: <chloe>
 { $values { "path" "a pathname string without the trailing " { $snippet ".xml" } " extension" } { "chloe" chloe } }
diff --git a/basis/html/templates/chloe/chloe.factor b/basis/html/templates/chloe/chloe.factor
index 1fe90b08d3..f42a5c3bde 100644
--- a/basis/html/templates/chloe/chloe.factor
+++ b/basis/html/templates/chloe/chloe.factor
@@ -1,11 +1,11 @@
 ! Copyright (C) 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors kernel sequences combinators kernel fry
+USING: accessors kernel sequences combinators fry
 namespaces make classes.tuple assocs splitting words arrays io
 io.files io.files.info io.encodings.utf8 io.streams.string
 unicode.case mirrors math urls present multiline quotations xml
 logging
-xml.data xml.writer xml.syntax strings
+xml.writer xml.syntax strings
 html.forms
 html
 html.components
diff --git a/basis/html/templates/chloe/syntax/syntax.factor b/basis/html/templates/chloe/syntax/syntax.factor
index 7c47a44d9e..f7da0fe277 100644
--- a/basis/html/templates/chloe/syntax/syntax.factor
+++ b/basis/html/templates/chloe/syntax/syntax.factor
@@ -1,13 +1,11 @@
 ! Copyright (C) 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-IN: html.templates.chloe.syntax
-USING: accessors kernel sequences combinators kernel namespaces
-classes.tuple assocs splitting words arrays memoize parser lexer
-io io.files io.encodings.utf8 io.streams.string
-unicode.case mirrors fry math urls
-multiline xml xml.data xml.writer xml.syntax
-html.components
+USING: accessors sequences combinators kernel namespaces classes.tuple
+assocs splitting words arrays memoize parser lexer io io.files
+io.encodings.utf8 io.streams.string unicode.case mirrors fry math urls
+multiline xml xml.data xml.writer xml.syntax html.components
 html.templates ;
+IN: html.templates.chloe.syntax
 
 SYMBOL: tags
 
diff --git a/basis/html/templates/fhtml/fhtml.factor b/basis/html/templates/fhtml/fhtml.factor
index 21e9f8352d..34783a0b4a 100644
--- a/basis/html/templates/fhtml/fhtml.factor
+++ b/basis/html/templates/fhtml/fhtml.factor
@@ -60,7 +60,7 @@ SYNTAX: %> lexer get parse-%> ;
     [
         "quiet" on
         parser-notes off
-        "html.templates.fhtml" use+
+        "html.templates.fhtml" use-vocab
         string-lines parse-template-lines
     ] with-file-vocabs ;
 
diff --git a/basis/http/server/server.factor b/basis/http/server/server.factor
index 3beb730499..c838471e3f 100755
--- a/basis/http/server/server.factor
+++ b/basis/http/server/server.factor
@@ -17,7 +17,6 @@ io.servers.connection
 io.timeouts
 io.crlf
 fry logging logging.insomniac calendar urls urls.encoding
-mime.multipart
 unicode.categories
 http
 http.parsers
@@ -27,6 +26,7 @@ html.templates
 html.streams
 html
 xml.writer ;
+FROM: mime.multipart => parse-multipart ;
 IN: http.server
 
 : check-absolute ( url -- url )
@@ -283,8 +283,6 @@ M: http-server handle-client*
 : http-insomniac ( -- )
     "http.server" { "httpd-hit" } schedule-insomniac ;
 
-USE: vocabs.loader
-
 "http.server.filters" require
 "http.server.dispatchers" require
 "http.server.redirection" require
diff --git a/basis/inverse/inverse.factor b/basis/inverse/inverse.factor
index 4e807bd992..7690b34410 100755
--- a/basis/inverse/inverse.factor
+++ b/basis/inverse/inverse.factor
@@ -1,7 +1,7 @@
 ! Copyright (C) 2007, 2009 Daniel Ehrenberg.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors kernel words summary slots quotations
-sequences assocs math arrays stack-checker effects generalizations
+sequences assocs math arrays stack-checker effects
 continuations debugger classes.tuple namespaces make vectors
 bit-arrays byte-arrays strings sbufs math.functions macros
 sequences.private combinators mirrors splitting combinators.smart
diff --git a/basis/io/encodings/gb18030/gb18030.factor b/basis/io/encodings/gb18030/gb18030.factor
index cecf103162..2be709dbc9 100644
--- a/basis/io/encodings/gb18030/gb18030.factor
+++ b/basis/io/encodings/gb18030/gb18030.factor
@@ -2,8 +2,9 @@
 ! See http://factorcode.org/license.txt for BSD license.
 USING: xml xml.data kernel io io.encodings interval-maps splitting fry
 math.parser sequences combinators assocs locals accessors math arrays
-byte-arrays values io.encodings.ascii ascii io.files biassocs
-math.order combinators.short-circuit io.binary io.encodings.iana ;
+byte-arrays values ascii io.files biassocs math.order
+combinators.short-circuit io.binary io.encodings.iana ;
+FROM: io.encodings.ascii => ascii ;
 IN: io.encodings.gb18030
 
 SINGLETON: gb18030
diff --git a/basis/io/mmap/mmap.factor b/basis/io/mmap/mmap.factor
index e03d5fb30b..9a4443e8e5 100644
--- a/basis/io/mmap/mmap.factor
+++ b/basis/io/mmap/mmap.factor
@@ -2,7 +2,7 @@
 ! See http://factorcode.org/license.txt for BSD license.
 USING: continuations destructors io.files io.files.info
 io.backend kernel quotations system alien alien.accessors
-accessors system vocabs.loader combinators alien.c-types
+accessors vocabs.loader combinators alien.c-types
 math ;
 IN: io.mmap
 
diff --git a/basis/locals/locals-tests.factor b/basis/locals/locals-tests.factor
index 1549a77663..414b2da45c 100644
--- a/basis/locals/locals-tests.factor
+++ b/basis/locals/locals-tests.factor
@@ -126,14 +126,6 @@ write-test-2 "q" set
 
 [ 9 ] [ 4 write-test-5 ] unit-test
 
-SYMBOL: a
-
-:: use-test ( a b c -- a b c )
-    USE: kernel
-    a b c ;
-
-[ t ] [ a symbol? ] unit-test
-
 :: let-let-test ( n -- n ) [let | n [ n 3 + ] | n ] ;
 
 [ 13 ] [ 10 let-let-test ] unit-test
diff --git a/basis/peg/ebnf/ebnf.factor b/basis/peg/ebnf/ebnf.factor
index 94df4ca209..d4ad62fbea 100644
--- a/basis/peg/ebnf/ebnf.factor
+++ b/basis/peg/ebnf/ebnf.factor
@@ -461,7 +461,7 @@ M: ebnf-sequence build-locals ( code ast -- code )
 
 M: ebnf-var build-locals ( code ast -- )
   [
-    "USING: locals kernel ;  [let* | " %
+    "FROM: locals => [let* ; FROM: kernel => dup ; [let* | " %
     name>> % " [ dup ] " %
     " | " %
     %  
diff --git a/basis/random/dummy/dummy.factor b/basis/random/dummy/dummy.factor
index e0cb83c330..dadf93fd43 100644
--- a/basis/random/dummy/dummy.factor
+++ b/basis/random/dummy/dummy.factor
@@ -1,4 +1,4 @@
-USING: kernel random math accessors random ;
+USING: kernel math accessors random ;
 IN: random.dummy
 
 TUPLE: random-dummy i ;
diff --git a/basis/regexp/classes/classes.factor b/basis/regexp/classes/classes.factor
index a1c4e3ca2a..e3e2f0bcf3 100644
--- a/basis/regexp/classes/classes.factor
+++ b/basis/regexp/classes/classes.factor
@@ -1,9 +1,10 @@
 ! Copyright (C) 2008, 2009 Doug Coleman, Daniel Ehrenberg.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors kernel math math.order words combinators locals
-ascii unicode.categories combinators.short-circuit sequences
+unicode.categories combinators.short-circuit sequences
 fry macros arrays assocs sets classes mirrors unicode.script
 unicode.data ;
+FROM: ascii => ascii? ;
 IN: regexp.classes
 
 SINGLETONS: dot letter-class LETTER-class Letter-class digit-class
diff --git a/basis/soundex/soundex.factor b/basis/soundex/soundex.factor
index 2fd928252f..37eaf08822 100644
--- a/basis/soundex/soundex.factor
+++ b/basis/soundex/soundex.factor
@@ -1,6 +1,6 @@
 ! Copyright (C) 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: sequences grouping assocs kernel ascii ascii tr ;
+USING: sequences grouping assocs kernel ascii tr ;
 IN: soundex
 
 TR: soundex-tr
diff --git a/basis/tools/files/unix/unix.factor b/basis/tools/files/unix/unix.factor
index 90e91529a1..d5fdd6c889 100755
--- a/basis/tools/files/unix/unix.factor
+++ b/basis/tools/files/unix/unix.factor
@@ -4,7 +4,7 @@ USING: accessors combinators kernel system unicode.case io.files
 io.files.info io.files.info.unix generalizations
 strings arrays sequences math.parser unix.groups unix.users
 tools.files.private unix.stat math fry macros combinators.smart
-io.files.info.unix io tools.files math.order prettyprint ;
+io tools.files math.order prettyprint ;
 IN: tools.files.unix
 
 <PRIVATE
diff --git a/basis/ui/tools/listener/completion/completion.factor b/basis/ui/tools/listener/completion/completion.factor
index fdba400c3d..f215e297ff 100644
--- a/basis/ui/tools/listener/completion/completion.factor
+++ b/basis/ui/tools/listener/completion/completion.factor
@@ -20,7 +20,7 @@ SLOT: history
     [ dup string>> { { CHAR: \n CHAR: \s } } substitute ] { } map>assoc
     <reversed> ;
 
-TUPLE: word-completion vocabs ;
+TUPLE: word-completion manifest ;
 C: <word-completion> word-completion
 
 SINGLETONS: vocab-completion char-completion history-completion ;
@@ -62,8 +62,8 @@ M: definition-completion row-columns
     2array ;
 
 M: word-completion row-color
-    [ vocabulary>> ] [ vocabs>> ] bi* {
-        { [ 2dup [ vocab-words ] dip memq? ] [ COLOR: black ] }
+    [ vocabulary>> ] [ manifest>> ] bi* {
+        { [ 2dup search-vocabs>> memq? ] [ COLOR: black ] }
         { [ over ".private" tail? ] [ COLOR: dark-red ] }
         [ COLOR: dark-gray ]
     } cond 2nip ;
@@ -87,7 +87,7 @@ M: vocab-completion row-color
     [ { 0 0 } ] 2dip doc-range ;
 
 : completion-mode ( interactor -- symbol )
-    [ vocabs>> ] [ editor-caret ] [ model>> ] tri up-to-caret " \r\n" split
+    [ manifest>> ] [ editor-caret ] [ model>> ] tri up-to-caret " \r\n" split
     {
         { [ dup { [ complete-IN:/USE:? ] [ complete-USING:? ] } 1|| ] [ 2drop vocab-completion ] }
         { [ dup complete-CHAR:? ] [ 2drop char-completion ] }
diff --git a/basis/ui/tools/listener/listener.factor b/basis/ui/tools/listener/listener.factor
index 19328b0b31..2e89482c3d 100644
--- a/basis/ui/tools/listener/listener.factor
+++ b/basis/ui/tools/listener/listener.factor
@@ -55,7 +55,7 @@ M: vocab-completion (word-at-caret)
     drop dup vocab-exists? [ >vocab-link ] [ drop f ] if ;
 
 M: word-completion (word-at-caret)
-    manifest>> search-manifest ;
+    manifest>> dup [ search-manifest ] [ 2drop f ] if ;
 
 M: char-completion (word-at-caret)
     2drop f ;
diff --git a/basis/unicode/collation/collation.factor b/basis/unicode/collation/collation.factor
index b6eddccae0..f8beca3c60 100755
--- a/basis/unicode/collation/collation.factor
+++ b/basis/unicode/collation/collation.factor
@@ -1,11 +1,10 @@
 ! Copyright (C) 2008 Daniel Ehrenberg.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: combinators.short-circuit sequences io.files
-io.encodings.ascii kernel values splitting accessors math.parser
-ascii io assocs strings math namespaces make sorting combinators
-math.order arrays unicode.normalize unicode.data locals
-macros sequences.deep words unicode.breaks
-quotations combinators.short-circuit simple-flat-file ;
+USING: sequences io.files io.encodings.ascii kernel values splitting
+accessors math.parser ascii io assocs strings math namespaces make
+sorting combinators math.order arrays unicode.normalize unicode.data
+locals macros sequences.deep words unicode.breaks quotations
+combinators.short-circuit simple-flat-file ;
 IN: unicode.collation
 
 <PRIVATE
diff --git a/basis/xml/syntax/syntax.factor b/basis/xml/syntax/syntax.factor
index f39592036c..7561d67482 100644
--- a/basis/xml/syntax/syntax.factor
+++ b/basis/xml/syntax/syntax.factor
@@ -1,7 +1,7 @@
 ! Copyright (C) 2005, 2009 Daniel Ehrenberg
 ! See http://factorcode.org/license.txt for BSD license.
-USING: words assocs kernel accessors parser effects.parser
-sequences summary lexer splitting combinators locals xml.data
+USING: words assocs kernel accessors parser vocabs.parser effects.parser
+sequences summary lexer splitting combinators locals
 memoize sequences.deep xml.data xml.state xml namespaces present
 arrays generalizations strings make math macros multiline
 inverse combinators.short-circuit sorting fry unicode.categories
diff --git a/basis/xmode/code2html/code2html.factor b/basis/xmode/code2html/code2html.factor
index b5141f6cc4..a4c2094da7 100644
--- a/basis/xmode/code2html/code2html.factor
+++ b/basis/xmode/code2html/code2html.factor
@@ -1,6 +1,6 @@
-USING: xmode.tokens xmode.marker xmode.catalog kernel locals
-io io.files sequences words io.encodings.utf8
-namespaces xml.entities accessors xml.syntax locals xml.writer ;
+USING: xmode.tokens xmode.marker xmode.catalog kernel io io.files
+sequences words io.encodings.utf8 namespaces xml.entities accessors
+xml.syntax locals xml.writer ;
 IN: xmode.code2html
 
 : htmlize-tokens ( tokens -- xml )
diff --git a/basis/xmode/marker/marker.factor b/basis/xmode/marker/marker.factor
index b4c1cd6a48..febfc2b40f 100755
--- a/basis/xmode/marker/marker.factor
+++ b/basis/xmode/marker/marker.factor
@@ -3,8 +3,7 @@
 USING: kernel namespaces make xmode.rules xmode.tokens
 xmode.marker.state xmode.marker.context xmode.utilities
 xmode.catalog sequences math assocs combinators strings
-regexp splitting unicode.case ascii
-combinators.short-circuit accessors ;
+regexp splitting ascii combinators.short-circuit accessors ;
 IN: xmode.marker
 
 ! Next two words copied from parser-combinators
diff --git a/extra/4DNav/turtle/turtle.factor b/extra/4DNav/turtle/turtle.factor
index 664645c466..71f7f26185 100755
--- a/extra/4DNav/turtle/turtle.factor
+++ b/extra/4DNav/turtle/turtle.factor
@@ -1,9 +1,6 @@
-USING: kernel math arrays math.vectors math.matrices
-namespaces make
-math.constants math.functions
-math.vectors
-splitting grouping math.trig
-  sequences accessors 4DNav.deep models vars ;
+USING: kernel math arrays math.vectors math.matrices namespaces make
+math.constants math.functions splitting grouping math.trig sequences
+accessors 4DNav.deep models vars ;
 IN: 4DNav.turtle
 
 ! replacement of self
diff --git a/extra/4DNav/window3D/window3D.factor b/extra/4DNav/window3D/window3D.factor
index 6bb57cf940..e83e884019 100755
--- a/extra/4DNav/window3D/window3D.factor
+++ b/extra/4DNav/window3D/window3D.factor
@@ -15,7 +15,6 @@ accessors
 namespaces
 adsoda 
 models
-accessors
 prettyprint
 ;
 
diff --git a/extra/benchmark/backtrack/backtrack.factor b/extra/benchmark/backtrack/backtrack.factor
index 0ae7d792dd..27040edac3 100755
--- a/extra/benchmark/backtrack/backtrack.factor
+++ b/extra/benchmark/backtrack/backtrack.factor
@@ -1,7 +1,7 @@
 ! Copyright (C) 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: backtrack shuffle math math.ranges quotations locals fry
-kernel words io memoize macros io prettyprint sequences assocs
+kernel words io memoize macros prettyprint sequences assocs
 combinators namespaces ;
 IN: benchmark.backtrack
 
diff --git a/extra/bunny/outlined/outlined.factor b/extra/bunny/outlined/outlined.factor
index 7d614ff947..8856032488 100755
--- a/extra/bunny/outlined/outlined.factor
+++ b/extra/bunny/outlined/outlined.factor
@@ -3,6 +3,7 @@ destructors kernel math multiline opengl opengl.shaders
 opengl.framebuffers opengl.gl opengl.textures opengl.demo-support fry
 opengl.capabilities sequences ui.gadgets combinators accessors
 macros locals ;
+FROM: opengl.demo-support => rect-vertices ;
 IN: bunny.outlined
 
 STRING: outlined-pass1-fragment-shader-main-source
diff --git a/extra/fjsc/fjsc.factor b/extra/fjsc/fjsc.factor
index bc6b8a092f..b6b5ff3b08 100755
--- a/extra/fjsc/fjsc.factor
+++ b/extra/fjsc/fjsc.factor
@@ -2,8 +2,7 @@
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors kernel peg strings sequences math math.parser
 namespaces make words quotations arrays hashtables io
-io.streams.string assocs ascii peg.parsers accessors
-words.symbol ;
+io.streams.string assocs ascii peg.parsers words.symbol ;
 IN: fjsc
 
 TUPLE: ast-number value ;
diff --git a/extra/fuel/eval/eval.factor b/extra/fuel/eval/eval.factor
index 9f0b6fc0a3..7c83fc6e90 100644
--- a/extra/fuel/eval/eval.factor
+++ b/extra/fuel/eval/eval.factor
@@ -6,7 +6,7 @@ vectors vocabs.parser ;
 
 IN: fuel.eval
 
-TUPLE: fuel-status in use restarts ;
+TUPLE: fuel-status manifest restarts ;
 
 SYMBOL: fuel-status-stack
 V{ } clone fuel-status-stack set-global
@@ -24,7 +24,7 @@ t fuel-eval-res-flag set-global
     fuel-eval-res-flag get-global ;
 
 : fuel-push-status ( -- )
-    in get use get clone restarts get-global clone
+    manifest get clone restarts get-global clone
     fuel-status boa
     fuel-status-stack get push ;
 
@@ -34,9 +34,9 @@ t fuel-eval-res-flag set-global
 : fuel-pop-status ( -- )
     fuel-status-stack get empty? [
         fuel-status-stack get pop
-        [ in>> in set ]
-        [ use>> clone use set ]
-        [ restarts>> fuel-pop-restarts ] tri
+        [ manifest>> clone manifest set ]
+        [ restarts>> fuel-pop-restarts ]
+        bi
     ] unless ;
 
 : fuel-forget-error ( -- ) f error set-global ;
@@ -60,11 +60,11 @@ t fuel-eval-res-flag set-global
     [ print-error ] recover ;
 
 : (fuel-eval-usings) ( usings -- )
-    [ [ add-use ] curry [ drop ] recover ] each
+    [ [ use-vocab ] curry [ drop ] recover ] each
     fuel-forget-error fuel-forget-output ;
 
 : (fuel-eval-in) ( in -- )
-    [ in set ] when* ;
+    [ set-current-vocab ] when* ;
 
 : (fuel-eval-in-context) ( lines in usings -- )
     (fuel-begin-eval)
diff --git a/extra/fuel/xref/xref.factor b/extra/fuel/xref/xref.factor
index 160b7212c4..3dfa129a7f 100644
--- a/extra/fuel/xref/xref.factor
+++ b/extra/fuel/xref/xref.factor
@@ -35,7 +35,11 @@ MEMO: (vocab-words) ( name -- seq )
     >vocab-link words [ name>> ] map ;
 
 : current-words ( -- seq )
-    use get [ keys ] map concat ; inline
+    manifest get
+    [ search-vocabs>> [ words>> ] map ]
+    [ qualified-vocabs>> [ words>> ] map ]
+    [ extra-words>> ]
+    tri 3append assoc-combine keys ; inline
 
 : vocabs-words ( names -- seq )
     prune [ (vocab-words) ] map concat ; inline
diff --git a/extra/google-tech-talk/google-tech-talk.factor b/extra/google-tech-talk/google-tech-talk.factor
index 8e2eeeb1a7..5f33af04fe 100644
--- a/extra/google-tech-talk/google-tech-talk.factor
+++ b/extra/google-tech-talk/google-tech-talk.factor
@@ -1,7 +1,7 @@
 ! Copyright (C) 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: slides help.markup math arrays hashtables namespaces
-sequences kernel sequences parser memoize io.encodings.binary
+kernel sequences parser memoize io.encodings.binary
 locals kernel.private help.vocabs assocs quotations
 urls peg.ebnf tools.annotations tools.crossref
 help.topics math.functions compiler.tree.optimizer
diff --git a/extra/hashcash/hashcash.factor b/extra/hashcash/hashcash.factor
index 1eb690b20f..a77ebf2577 100755
--- a/extra/hashcash/hashcash.factor
+++ b/extra/hashcash/hashcash.factor
@@ -1,9 +1,8 @@
 ! Copyright (C) 2009 Diego Martinelli.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors byte-arrays calendar calendar.format 
-checksums checksums.openssl classes.tuple 
-fry kernel make math math.functions math.parser math.ranges 
-present random sequences splitting strings syntax ;
+USING: accessors byte-arrays calendar calendar.format checksums
+checksums.openssl classes.tuple fry kernel make math math.functions
+math.parser math.ranges present random sequences splitting strings ;
 IN: hashcash
 
 ! Hashcash implementation
diff --git a/extra/html/parser/analyzer/analyzer.factor b/extra/html/parser/analyzer/analyzer.factor
index 2196f1baaa..02b45ee939 100755
--- a/extra/html/parser/analyzer/analyzer.factor
+++ b/extra/html/parser/analyzer/analyzer.factor
@@ -1,7 +1,7 @@
 ! Copyright (C) 2008 Doug Coleman.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: assocs html.parser kernel math sequences strings ascii
-arrays generalizations shuffle unicode.case namespaces make
+arrays generalizations shuffle namespaces make
 splitting http accessors io combinators http.client urls
 urls.encoding fry prettyprint sets ;
 IN: html.parser.analyzer
diff --git a/extra/id3/id3.factor b/extra/id3/id3.factor
index 6acace8582..6d9b778ee8 100644
--- a/extra/id3/id3.factor
+++ b/extra/id3/id3.factor
@@ -1,7 +1,7 @@
 ! Copyright (C) 2009 Tim Wawrzynczak, Doug Coleman.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: sequences io io.encodings.binary io.files io.pathnames
-strings kernel math io.mmap io.mmap.uchar accessors syntax
+strings kernel math io.mmap io.mmap.uchar accessors
 combinators math.ranges unicode.categories byte-arrays
 io.encodings.string io.encodings.utf16 assocs math.parser
 combinators.short-circuit fry namespaces combinators.smart
diff --git a/extra/infix/infix.factor b/extra/infix/infix.factor
index 09f1b0e4b1..ce19780058 100644
--- a/extra/infix/infix.factor
+++ b/extra/infix/infix.factor
@@ -3,7 +3,7 @@
 USING: accessors assocs combinators combinators.short-circuit
 effects fry infix.parser infix.ast kernel locals.parser
 locals.types math multiline namespaces parser quotations
-sequences summary words ;
+sequences summary words vocabs.parser ;
 IN: infix
 
 <PRIVATE
diff --git a/extra/jamshred/tunnel/tunnel.factor b/extra/jamshred/tunnel/tunnel.factor
index 6171c3053b..7e124dc713 100644
--- a/extra/jamshred/tunnel/tunnel.factor
+++ b/extra/jamshred/tunnel/tunnel.factor
@@ -1,6 +1,7 @@
 ! Copyright (C) 2007, 2008 Alex Chapman
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors arrays colors combinators kernel literals locals math math.constants math.matrices math.order math.ranges math.vectors math.quadratic random sequences specialized-arrays.float vectors jamshred.oint ;
+FROM: jamshred.oint => distance ;
 IN: jamshred.tunnel
 
 CONSTANT: n-segments 5000
diff --git a/extra/koszul/koszul.factor b/extra/koszul/koszul.factor
index 4ba8e2f66b..1ecd56d416 100755
--- a/extra/koszul/koszul.factor
+++ b/extra/koszul/koszul.factor
@@ -1,6 +1,6 @@
 ! Copyright (C) 2006, 2007 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors arrays assocs hashtables assocs io kernel math
+USING: accessors arrays hashtables assocs io kernel math
 math.vectors math.matrices math.matrices.elimination namespaces
 parser prettyprint sequences words combinators math.parser
 splitting sorting shuffle sets math.order ;
diff --git a/extra/mason/common/common.factor b/extra/mason/common/common.factor
index a33e3c5831..4ac5767009 100755
--- a/extra/mason/common/common.factor
+++ b/extra/mason/common/common.factor
@@ -4,7 +4,7 @@ USING: kernel namespaces sequences splitting system accessors
 math.functions make io io.files io.pathnames io.directories
 io.directories.hierarchy io.launcher io.encodings.utf8 prettyprint
 combinators.short-circuit parser combinators calendar
-calendar.format arrays mason.config locals system debugger fry
+calendar.format arrays mason.config locals debugger fry
 continuations strings ;
 IN: mason.common
 
diff --git a/extra/mason/mason.factor b/extra/mason/mason.factor
index d425985e76..8818e1cc94 100644
--- a/extra/mason/mason.factor
+++ b/extra/mason/mason.factor
@@ -1,8 +1,9 @@
 ! Copyright (C) 2008 Eduardo Cavazos, Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors calendar continuations debugger debugger io
-io.directories io.files kernel mason.build mason.common
+USING: accessors calendar continuations debugger io
+io.directories io.files kernel mason.common
 mason.email mason.updates namespaces threads ;
+FROM: mason.build => build ;
 IN: mason
 
 : build-loop-error ( error -- )
diff --git a/extra/mason/release/release.factor b/extra/mason/release/release.factor
index fc4ad0b08a..a593f000f3 100644
--- a/extra/mason/release/release.factor
+++ b/extra/mason/release/release.factor
@@ -1,6 +1,6 @@
 ! Copyright (C) 2008, 2009 Eduardo Cavazos, Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: kernel debugger namespaces sequences splitting combinators
+USING: kernel debugger namespaces sequences splitting
 combinators io io.files io.launcher prettyprint bootstrap.image
 mason.common mason.release.branch mason.release.tidy
 mason.release.archive mason.release.upload mason.notify ;
diff --git a/extra/mongodb/benchmark/benchmark.factor b/extra/mongodb/benchmark/benchmark.factor
index 02dfa8add9..a977224d66 100644
--- a/extra/mongodb/benchmark/benchmark.factor
+++ b/extra/mongodb/benchmark/benchmark.factor
@@ -1,7 +1,7 @@
 USING: calendar math fry kernel assocs math.ranges bson.reader io.streams.byte-array
 sequences formatting combinators namespaces io tools.time prettyprint io.encodings.binary
-accessors words mongodb.driver strings math.parser tools.walker bson.writer
-tools.continuations ;
+accessors words mongodb.driver strings math.parser bson.writer ;
+FROM: mongodb.driver => find ;
 
 IN: mongodb.benchmark
 
diff --git a/extra/mongodb/tuple/tuple.factor b/extra/mongodb/tuple/tuple.factor
index 677fa09bf9..ce76a37ff4 100644
--- a/extra/mongodb/tuple/tuple.factor
+++ b/extra/mongodb/tuple/tuple.factor
@@ -2,6 +2,8 @@ USING: accessors assocs classes.mixin classes.tuple
 classes.tuple.parser compiler.units fry kernel sequences mongodb.driver
 mongodb.msg mongodb.tuple.collection 
 mongodb.tuple.persistent mongodb.tuple.state strings ;
+FROM: mongodb.driver => update delete find count ;
+FROM: mongodb.tuple.persistent => assoc>tuple ;
 
 IN: mongodb.tuple
 
diff --git a/extra/otug-talk/otug-talk.factor b/extra/otug-talk/otug-talk.factor
index 35a83a63de..0e7702512f 100644
--- a/extra/otug-talk/otug-talk.factor
+++ b/extra/otug-talk/otug-talk.factor
@@ -1,7 +1,7 @@
 ! Copyright (C) 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: slides help.markup math arrays hashtables namespaces
-sequences kernel sequences parser memoize io.encodings.binary
+kernel sequences parser memoize io.encodings.binary
 locals kernel.private help.vocabs assocs quotations
 tools.annotations tools.crossref help.topics math.functions
 compiler.tree.optimizer compiler.cfg.optimizer fry
diff --git a/extra/peg/javascript/parser/parser.factor b/extra/peg/javascript/parser/parser.factor
index 7ace528150..82b50c454a 100644
--- a/extra/peg/javascript/parser/parser.factor
+++ b/extra/peg/javascript/parser/parser.factor
@@ -1,6 +1,7 @@
 ! Copyright (C) 2008 Chris Double.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: kernel accessors peg peg.ebnf peg.javascript.ast peg.javascript.tokenizer ;
+USING: kernel accessors sequences
+peg peg.ebnf peg.javascript.ast peg.javascript.tokenizer ;
 IN: peg.javascript.parser
 
 #! Grammar for JavaScript. Based on OMeta-JS example from:
diff --git a/extra/project-euler/common/common.factor b/extra/project-euler/common/common.factor
index 84291f2ce8..497fc31de7 100644
--- a/extra/project-euler/common/common.factor
+++ b/extra/project-euler/common/common.factor
@@ -143,6 +143,6 @@ PRIVATE>
 SYNTAX: SOLUTION:
     scan-word
     [ name>> "-main" append create-in ] keep
-    [ drop in get vocab (>>main) ]
+    [ drop current-vocab (>>main) ]
     [ [ . ] swap prefix (( -- )) define-declared ]
     2bi ;
diff --git a/extra/spheres/spheres.factor b/extra/spheres/spheres.factor
index 710c953ed1..1a8f41b4a2 100755
--- a/extra/spheres/spheres.factor
+++ b/extra/spheres/spheres.factor
@@ -3,6 +3,7 @@ opengl.shaders opengl.framebuffers opengl.capabilities multiline
 ui.gadgets accessors sequences ui.render ui math locals arrays
 generalizations combinators ui.gadgets.worlds
 literals ui.pixel-formats ;
+FROM: opengl.demo-support => rect-vertices ;
 IN: spheres
 
 STRING: plane-vertex-shader
diff --git a/extra/tetris/tetris.factor b/extra/tetris/tetris.factor
index 66f69bb053..dbdb666e4a 100644
--- a/extra/tetris/tetris.factor
+++ b/extra/tetris/tetris.factor
@@ -1,6 +1,7 @@
 ! Copyright (C) 2006, 2007, 2008 Alex Chapman
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors alarms arrays calendar kernel make math math.rectangles math.parser namespaces sequences system tetris.game tetris.gl ui.gadgets ui.gadgets.labels ui.gadgets.worlds ui.gadgets.status-bar ui.gestures ui.render ui ;
+FROM: tetris.game => level>> ;
 IN: tetris
 
 TUPLE: tetris-gadget < gadget { tetris tetris } { alarm } ;
diff --git a/extra/ui/gadgets/book-extras/book-extras.factor b/extra/ui/gadgets/book-extras/book-extras.factor
index b9d859962f..9e94747919 100644
--- a/extra/ui/gadgets/book-extras/book-extras.factor
+++ b/extra/ui/gadgets/book-extras/book-extras.factor
@@ -1,4 +1,5 @@
 USING: accessors kernel fry math models ui.gadgets ui.gadgets.books ui.gadgets.buttons ;
+FROM: models => change-model ;
 IN: ui.gadgets.book-extras
 : <book*> ( pages -- book ) 0 <model> <book> ;
 : |<< ( book -- ) 0 swap set-control-value ;
diff --git a/extra/vpri-talk/vpri-talk.factor b/extra/vpri-talk/vpri-talk.factor
index 4ee499bf50..518462d7bb 100644
--- a/extra/vpri-talk/vpri-talk.factor
+++ b/extra/vpri-talk/vpri-talk.factor
@@ -1,7 +1,7 @@
 ! Copyright (C) 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: slides help.markup math arrays hashtables namespaces
-sequences kernel sequences parser memoize io.encodings.binary
+kernel sequences parser memoize io.encodings.binary
 locals kernel.private help.vocabs assocs quotations urls
 peg.ebnf tools.annotations tools.crossref help.topics
 math.functions compiler.tree.optimizer compiler.cfg.optimizer
diff --git a/extra/webapps/site-watcher/site-watcher.factor b/extra/webapps/site-watcher/site-watcher.factor
index f82eb6dcd8..5ecd3bc6a8 100644
--- a/extra/webapps/site-watcher/site-watcher.factor
+++ b/extra/webapps/site-watcher/site-watcher.factor
@@ -37,7 +37,7 @@ IN: webapps.site-watcher
             "twitter" value >>twitter
             "sms" value >>sms
             update-tuple
-            site-list-url <redirect>
+            f <redirect>
         ] >>submit
     <protected>
         "update notification details" >>description ;
diff --git a/extra/webapps/wiki/wiki.factor b/extra/webapps/wiki/wiki.factor
index 2341b020a8..5689f23d4e 100644
--- a/extra/webapps/wiki/wiki.factor
+++ b/extra/webapps/wiki/wiki.factor
@@ -15,7 +15,7 @@ furnace.auth.login
 furnace.boilerplate
 furnace.syndication
 validators
-db.types db.tuples lcs farkup urls ;
+db.types db.tuples lcs urls ;
 IN: webapps.wiki
 
 : wiki-url ( rest path -- url )
diff --git a/extra/sandbox/authors.txt b/unmaintained/sandbox/authors.txt
similarity index 100%
rename from extra/sandbox/authors.txt
rename to unmaintained/sandbox/authors.txt
diff --git a/extra/sandbox/sandbox-tests.factor b/unmaintained/sandbox/sandbox-tests.factor
similarity index 100%
rename from extra/sandbox/sandbox-tests.factor
rename to unmaintained/sandbox/sandbox-tests.factor
diff --git a/extra/sandbox/sandbox.factor b/unmaintained/sandbox/sandbox.factor
similarity index 100%
rename from extra/sandbox/sandbox.factor
rename to unmaintained/sandbox/sandbox.factor
diff --git a/extra/sandbox/summary.txt b/unmaintained/sandbox/summary.txt
similarity index 100%
rename from extra/sandbox/summary.txt
rename to unmaintained/sandbox/summary.txt
diff --git a/extra/sandbox/syntax/syntax.factor b/unmaintained/sandbox/syntax/syntax.factor
similarity index 100%
rename from extra/sandbox/syntax/syntax.factor
rename to unmaintained/sandbox/syntax/syntax.factor

From dedbd149458652e8fe1783da64acde1ead6ef210 Mon Sep 17 00:00:00 2001
From: Slava Pestov <slava@slava-pestovs-macbook-pro.local>
Date: Fri, 15 May 2009 17:18:38 -0500
Subject: [PATCH 07/23] Fix escape analysis bug reported by Doug

---
 .../escape-analysis/escape-analysis-tests.factor     |  6 ++++++
 .../tree/escape-analysis/simple/simple.factor        | 12 ++++--------
 2 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/basis/compiler/tree/escape-analysis/escape-analysis-tests.factor b/basis/compiler/tree/escape-analysis/escape-analysis-tests.factor
index 3d9d77ae56..708992f918 100644
--- a/basis/compiler/tree/escape-analysis/escape-analysis-tests.factor
+++ b/basis/compiler/tree/escape-analysis/escape-analysis-tests.factor
@@ -322,3 +322,9 @@ C: <ro-box> ro-box
 [ 0 ] [
     [ { null } declare [ 1 ] [ 2 ] if ] count-unboxed-allocations
 ] unit-test
+
+! Doug found a regression
+
+TUPLE: empty-tuple ;
+
+[ ] [ [ empty-tuple boa layout-of ] count-unboxed-allocations drop ] unit-test
\ No newline at end of file
diff --git a/basis/compiler/tree/escape-analysis/simple/simple.factor b/basis/compiler/tree/escape-analysis/simple/simple.factor
index 729d6a0490..c0b3982c0e 100644
--- a/basis/compiler/tree/escape-analysis/simple/simple.factor
+++ b/basis/compiler/tree/escape-analysis/simple/simple.factor
@@ -49,14 +49,10 @@ M: #push escape-analysis*
 
 : slot-offset ( #call -- n/f )
     dup in-d>>
-    [ first node-value-info class>> ]
-    [ second node-value-info literal>> ] 2bi
-    dup fixnum? [
-        {
-            { [ over tuple class<= ] [ 2 - ] }
-            { [ over complex class<= ] [ 1 - ] }
-            [ drop f ]
-        } cond nip
+    [ second node-value-info literal>> ]
+    [ first node-value-info class>> ] 2bi
+    2dup [ fixnum? ] [ tuple class<= ] bi* and [
+        over 2 >= [ drop 2 - ] [ 2drop f ] if
     ] [ 2drop f ] if ;
 
 : record-slot-call ( #call -- )

From 79f5c30a7ac0c039e852fad059aa9ff7519481bd Mon Sep 17 00:00:00 2001
From: Slava Pestov <slava@slava-pestovs-macbook-pro.local>
Date: Fri, 15 May 2009 17:18:56 -0500
Subject: [PATCH 08/23] serialize: Remove code for handling complex and ratio
 values since those are tuples now

---
 basis/serialize/serialize.factor | 18 ------------------
 1 file changed, 18 deletions(-)

diff --git a/basis/serialize/serialize.factor b/basis/serialize/serialize.factor
index 4a0d3777b8..4e94b6a51d 100644
--- a/basis/serialize/serialize.factor
+++ b/basis/serialize/serialize.factor
@@ -90,16 +90,6 @@ M: float (serialize) ( obj -- )
     CHAR: F write1
     double>bits serialize-cell ;
 
-M: complex (serialize) ( obj -- )
-    CHAR: c write1
-    [ real-part (serialize) ]
-    [ imaginary-part (serialize) ] bi ;
-
-M: ratio (serialize) ( obj -- )
-    CHAR: r write1
-    [ numerator (serialize) ]
-    [ denominator (serialize) ] bi ;
-
 : serialize-seq ( obj code -- )
     [
         write1
@@ -205,12 +195,6 @@ SYMBOL: deserialized
 : deserialize-float ( -- float )
     deserialize-cell bits>double ;
 
-: deserialize-ratio ( -- ratio )
-    (deserialize) (deserialize) / ;
-
-: deserialize-complex ( -- complex )
-    (deserialize) (deserialize) rect> ;
-
 : (deserialize-string) ( -- string )
     deserialize-cell read utf8 decode ;
 
@@ -279,7 +263,6 @@ SYMBOL: deserialized
             { CHAR: T [ deserialize-tuple ] }
             { CHAR: W [ deserialize-wrapper ] }
             { CHAR: a [ deserialize-array ] }
-            { CHAR: c [ deserialize-complex ] }
             { CHAR: h [ deserialize-hashtable ] }
             { CHAR: m [ deserialize-negative-integer ] }
             { CHAR: n [ deserialize-false ] }
@@ -287,7 +270,6 @@ SYMBOL: deserialized
             { CHAR: o [ deserialize-unknown ] }
             { CHAR: p [ deserialize-positive-integer ] }
             { CHAR: q [ deserialize-quotation ] }
-            { CHAR: r [ deserialize-ratio ] }
             { CHAR: s [ deserialize-string ] }
             { CHAR: w [ deserialize-word ] }
             { CHAR: G [ deserialize-word ] }

From 66a94164730717940abb06a806cf3e6c5aa43986 Mon Sep 17 00:00:00 2001
From: Slava Pestov <slava@slava-pestovs-macbook-pro.local>
Date: Sat, 16 May 2009 00:29:21 -0500
Subject: [PATCH 09/23] Update documentation for stricter vocabulary search
 path semantics

---
 basis/checksums/openssl/openssl-docs.factor   |   4 +-
 basis/compiler/tests/alien.factor             |  11 +-
 basis/compiler/tests/codegen.factor           |  12 +-
 basis/compiler/tests/intrinsics.factor        |   4 +-
 .../tree/propagation/info/info-tests.factor   |   2 +-
 .../tuple-unboxing-tests.factor               |   2 +-
 .../distributed/distributed-tests.factor      |   1 +
 .../exchangers/exchangers-tests.factor        |   3 +-
 .../messaging/messaging-docs.factor           |   2 +-
 .../cpu/ppc/assembler/assembler-tests.factor  |   1 +
 basis/db/tuples/tuples-tests.factor           |   3 +-
 basis/ftp/server/server-tests.factor          |   1 +
 basis/help/cookbook/cookbook.factor           |   5 +-
 basis/help/handbook/handbook.factor           |   6 +-
 basis/help/tutorial/tutorial.factor           |   2 +-
 basis/html/components/components-tests.factor |   1 +
 basis/html/forms/forms-tests.factor           |   1 +
 basis/html/streams/streams-tests.factor       |   2 +-
 basis/html/templates/chloe/chloe-tests.factor |   2 +-
 basis/http/http-tests.factor                  |   8 +-
 basis/io/files/info/info-tests.factor         |   2 +-
 basis/listener/listener-tests.factor          |   2 -
 .../lists/lazy/examples/examples-tests.factor |   2 +-
 basis/lists/lazy/lazy-docs.factor             |  16 +-
 basis/lists/lazy/lazy.factor                  |   6 -
 basis/lists/lists-docs.factor                 |  46 ++--
 basis/lists/lists-tests.factor                |  39 +---
 basis/literals/literals-docs.factor           |   2 +-
 basis/math/complex/complex-docs.factor        |   4 +-
 basis/opengl/textures/textures-tests.factor   |   3 +-
 basis/peg/ebnf/ebnf.factor                    |   2 +-
 basis/peg/peg-tests.factor                    |   2 +-
 basis/prettyprint/prettyprint-tests.factor    |   4 +-
 basis/regexp/regexp-docs.factor               |   2 +-
 basis/serialize/serialize-tests.factor        |   2 +-
 .../call-effect/call-effect-tests.factor      |   2 +-
 .../struct-arrays/struct-arrays-tests.factor  |   3 +-
 basis/ui/gadgets/gadgets-tests.factor         |   9 +-
 basis/ui/tools/listener/listener-tests.factor |   4 +-
 basis/xml/syntax/syntax-docs.factor           |   4 +-
 basis/xml/syntax/syntax-tests.factor          |   2 -
 core/assocs/assocs-docs.factor                |   2 +-
 core/bootstrap/syntax.factor                  |   1 +
 core/classes/algebra/algebra-tests.factor     |   2 +-
 core/classes/classes-tests.factor             |   2 +-
 core/classes/mixin/mixin-tests.factor         |  11 +-
 core/classes/predicate/predicate-tests.factor |   2 +-
 core/combinators/combinators-docs.factor      |   2 -
 core/make/make-docs.factor                    |   2 +-
 core/parser/parser-docs.factor                |  11 +-
 core/parser/parser-tests.factor               |  18 +-
 core/syntax/syntax-docs.factor                |  52 +++--
 core/syntax/syntax.factor                     |   2 +
 core/vocabs/parser/parser-docs.factor         | 219 +++++++++++-------
 core/vocabs/parser/parser.factor              |  33 ++-
 core/words/words-docs.factor                  |   2 +-
 extra/bank/bank-tests.factor                  |   1 +
 extra/fuel/xref/xref.factor                   |   6 +-
 extra/infix/infix-docs.factor                 |   8 +-
 .../floating-point-tests.factor               |   4 +-
 extra/monads/monads-tests.factor              |   1 +
 extra/roles/roles-tests.factor                |   1 +
 extra/tetris/game/game-tests.factor           |   1 +
 63 files changed, 307 insertions(+), 307 deletions(-)

diff --git a/basis/checksums/openssl/openssl-docs.factor b/basis/checksums/openssl/openssl-docs.factor
index 234e032406..b0cc8f9e53 100644
--- a/basis/checksums/openssl/openssl-docs.factor
+++ b/basis/checksums/openssl/openssl-docs.factor
@@ -30,8 +30,8 @@ ARTICLE: "checksums.openssl" "OpenSSL checksums"
 "An error thrown if the digest name is unrecognized:"
 { $subsection unknown-digest }
 "An example where we compute the SHA1 checksum of a string using the OpenSSL implementation of SHA1:"
-{ $example "USING: byte-arrays checksums checksums.openssl prettyprint ;" "\"hello world\" >byte-array openssl-sha1 checksum-bytes hex-string ." "\"2aae6c35c94fcfb415dbe95f408b9ce91ee846ed\"" }
+{ $example "USING: byte-arrays checksums checksums.openssl ;" "\"hello world\" >byte-array openssl-sha1 checksum-bytes hex-string ." "\"2aae6c35c94fcfb415dbe95f408b9ce91ee846ed\"" }
 "If we use the Factor implementation, we get the same result, just slightly slower:"
-{ $example "USING: byte-arrays checksums checksums.sha1 prettyprint ;" "\"hello world\" >byte-array sha1 checksum-bytes hex-string ." "\"2aae6c35c94fcfb415dbe95f408b9ce91ee846ed\"" } ;
+{ $example "USING: byte-arrays checksums checksums.sha1 ;" "\"hello world\" >byte-array sha1 checksum-bytes hex-string ." "\"2aae6c35c94fcfb415dbe95f408b9ce91ee846ed\"" } ;
 
 ABOUT: "checksums.openssl"
diff --git a/basis/compiler/tests/alien.factor b/basis/compiler/tests/alien.factor
index f7f24433d7..91215baf19 100755
--- a/basis/compiler/tests/alien.factor
+++ b/basis/compiler/tests/alien.factor
@@ -1,9 +1,8 @@
-USING: alien alien.c-types alien.syntax compiler kernel
-namespaces namespaces tools.test sequences stack-checker
-stack-checker.errors words arrays parser quotations
-continuations effects namespaces.private io io.streams.string
-memory system threads tools.test math accessors combinators
-specialized-arrays.float alien.libraries io.pathnames
+USING: alien alien.c-types alien.syntax compiler kernel namespaces
+sequences stack-checker stack-checker.errors words arrays parser
+quotations continuations effects namespaces.private io
+io.streams.string memory system threads tools.test math accessors
+combinators specialized-arrays.float alien.libraries io.pathnames
 io.backend ;
 IN: compiler.tests.alien
 
diff --git a/basis/compiler/tests/codegen.factor b/basis/compiler/tests/codegen.factor
index 8fbe13ce51..e0bc917f1c 100644
--- a/basis/compiler/tests/codegen.factor
+++ b/basis/compiler/tests/codegen.factor
@@ -1,9 +1,9 @@
-USING: generalizations accessors arrays compiler kernel
-kernel.private math hashtables.private math.private namespaces
-sequences sequences.private tools.test namespaces.private
-slots.private sequences.private byte-arrays alien
+USING: generalizations accessors arrays compiler kernel kernel.private
+math hashtables.private math.private namespaces sequences tools.test
+namespaces.private slots.private sequences.private byte-arrays alien
 alien.accessors layouts words definitions compiler.units io
 combinators vectors grouping make ;
+QUALIFIED: namespaces.private
 IN: compiler.tests.codegen
 
 ! Originally, this file did black box testing of templating
@@ -48,7 +48,7 @@ unit-test
 [ 3 ]
 [
     global [ 3 \ foo set ] bind
-    \ foo [ global >n get ndrop ] compile-call
+    \ foo [ global >n get namespaces.private:ndrop ] compile-call
 ] unit-test
 
 : blech ( x -- ) drop ;
@@ -62,7 +62,7 @@ unit-test
 [ 3 ]
 [
     global [ 3 \ foo set ] bind
-    \ foo [ global [ get ] swap >n call ndrop ] compile-call
+    \ foo [ global [ get ] swap >n call namespaces.private:ndrop ] compile-call
 ] unit-test
 
 [ 3 ]
diff --git a/basis/compiler/tests/intrinsics.factor b/basis/compiler/tests/intrinsics.factor
index 5ca0f3f109..d0cfc127e3 100644
--- a/basis/compiler/tests/intrinsics.factor
+++ b/basis/compiler/tests/intrinsics.factor
@@ -1,10 +1,10 @@
 USING: accessors arrays compiler.units kernel kernel.private math
 math.constants math.private sequences strings tools.test words
 continuations sequences.private hashtables.private byte-arrays
-strings.private system random layouts vectors
+system random layouts vectors
 sbufs strings.private slots.private alien math.order
 alien.accessors alien.c-types alien.syntax alien.strings
-namespaces libc sequences.private io.encodings.ascii
+namespaces libc io.encodings.ascii
 classes compiler ;
 IN: compiler.tests.intrinsics
 
diff --git a/basis/compiler/tree/propagation/info/info-tests.factor b/basis/compiler/tree/propagation/info/info-tests.factor
index 2c3314994b..72c08dbf1c 100644
--- a/basis/compiler/tree/propagation/info/info-tests.factor
+++ b/basis/compiler/tree/propagation/info/info-tests.factor
@@ -1,5 +1,5 @@
 USING: accessors math math.intervals sequences classes.algebra
-math kernel tools.test compiler.tree.propagation.info arrays ;
+kernel tools.test compiler.tree.propagation.info arrays ;
 IN: compiler.tree.propagation.info.tests
 
 [ f ] [ 0.0 -0.0 eql? ] unit-test
diff --git a/basis/compiler/tree/tuple-unboxing/tuple-unboxing-tests.factor b/basis/compiler/tree/tuple-unboxing/tuple-unboxing-tests.factor
index 0d5f05fab0..a96fc0501d 100644
--- a/basis/compiler/tree/tuple-unboxing/tuple-unboxing-tests.factor
+++ b/basis/compiler/tree/tuple-unboxing/tuple-unboxing-tests.factor
@@ -1,5 +1,5 @@
 IN: compiler.tree.tuple-unboxing.tests
-USING: tools.test compiler.tree.tuple-unboxing compiler.tree
+USING: tools.test compiler.tree
 compiler.tree.builder compiler.tree.recursive
 compiler.tree.normalization compiler.tree.propagation
 compiler.tree.cleanup compiler.tree.escape-analysis
diff --git a/basis/concurrency/distributed/distributed-tests.factor b/basis/concurrency/distributed/distributed-tests.factor
index 996e3db4c0..6c0d882cac 100644
--- a/basis/concurrency/distributed/distributed-tests.factor
+++ b/basis/concurrency/distributed/distributed-tests.factor
@@ -3,6 +3,7 @@ USING: tools.test concurrency.distributed kernel io.files
 io.files.temp io.directories arrays io.sockets system
 combinators threads math sequences concurrency.messaging
 continuations accessors prettyprint ;
+FROM: concurrency.messaging => receive send ;
 
 : test-node ( -- addrspec )
     {
diff --git a/basis/concurrency/exchangers/exchangers-tests.factor b/basis/concurrency/exchangers/exchangers-tests.factor
index 3b5b014fe3..7ec9db8ad9 100644
--- a/basis/concurrency/exchangers/exchangers-tests.factor
+++ b/basis/concurrency/exchangers/exchangers-tests.factor
@@ -1,7 +1,8 @@
 IN: concurrency.exchangers.tests
-USING: sequences tools.test concurrency.exchangers
+USING: tools.test concurrency.exchangers
 concurrency.count-downs concurrency.promises locals kernel
 threads ;
+FROM: sequences => 3append ;
 
 :: exchanger-test ( -- string )
     [let |
diff --git a/basis/concurrency/messaging/messaging-docs.factor b/basis/concurrency/messaging/messaging-docs.factor
index 039e9a53af..d58df3519b 100644
--- a/basis/concurrency/messaging/messaging-docs.factor
+++ b/basis/concurrency/messaging/messaging-docs.factor
@@ -53,7 +53,7 @@ ARTICLE: { "concurrency" "synchronous-sends" } "Synchronous sends"
 { $subsection reply-synchronous }
 "An example:"
 { $example
-    "USING: concurrency.messaging kernel prettyprint threads ;"
+    "USING: concurrency.messaging threads ;"
     "IN: scratchpad"
     ": pong-server ( -- )"
     "    receive [ \"pong\" ] dip reply-synchronous ;"
diff --git a/basis/cpu/ppc/assembler/assembler-tests.factor b/basis/cpu/ppc/assembler/assembler-tests.factor
index 14327d08b8..23b1d1e6f4 100644
--- a/basis/cpu/ppc/assembler/assembler-tests.factor
+++ b/basis/cpu/ppc/assembler/assembler-tests.factor
@@ -1,6 +1,7 @@
 IN: cpu.ppc.assembler.tests
 USING: cpu.ppc.assembler tools.test arrays kernel namespaces
 make vocabs sequences ;
+FROM: cpu.ppc.assembler => B ;
 
 : test-assembler ( expected quot -- )
     [ 1array ] [ [ B{ } make ] curry ] bi* unit-test ;
diff --git a/basis/db/tuples/tuples-tests.factor b/basis/db/tuples/tuples-tests.factor
index afdee3e89f..6bf8dd3075 100644
--- a/basis/db/tuples/tuples-tests.factor
+++ b/basis/db/tuples/tuples-tests.factor
@@ -1,11 +1,12 @@
 ! Copyright (C) 2008 Doug Coleman.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: io.files io.files.temp kernel tools.test db db.tuples classes
-db.types continuations namespaces math math.ranges
+db.types continuations namespaces math
 prettyprint calendar sequences db.sqlite math.intervals
 db.postgresql accessors random math.bitwise system
 math.ranges strings urls fry db.tuples.private db.private
 db.tester ;
+FROM: math.ranges => [a,b] ;
 IN: db.tuples.tests
 
 TUPLE: person the-id the-name the-number the-real
diff --git a/basis/ftp/server/server-tests.factor b/basis/ftp/server/server-tests.factor
index d7d9d8384d..3484fb4474 100644
--- a/basis/ftp/server/server-tests.factor
+++ b/basis/ftp/server/server-tests.factor
@@ -2,6 +2,7 @@ USING: calendar ftp.server io.encodings.ascii io.files
 io.files.unique namespaces threads tools.test kernel
 io.servers.connection ftp.client accessors urls
 io.pathnames io.directories sequences fry ;
+FROM: ftp.client => ftp-get ;
 IN: ftp.server.tests
 
 : test-file-contents ( -- string )
diff --git a/basis/help/cookbook/cookbook.factor b/basis/help/cookbook/cookbook.factor
index 8aa0265239..ff385f9a65 100644
--- a/basis/help/cookbook/cookbook.factor
+++ b/basis/help/cookbook/cookbook.factor
@@ -136,7 +136,7 @@ ARTICLE: "cookbook-variables" "Dynamic variables cookbook"
 } ;
 
 ARTICLE: "cookbook-vocabs" "Vocabularies cookbook"
-"Rather than being in one flat list, words belong to vocabularies; every word is contained in exactly one. When parsing a word name, the parser searches the " { $emphasis "vocabulary search path" } ". When working at the listener, a useful set of vocabularies is already available. In a source file, all used vocabularies must be imported."
+"Rather than being in one flat list, words belong to vocabularies; every word is contained in exactly one. When parsing a word name, the parser searches through vocabularies. When working at the listener, a useful set of vocabularies is already available. In a source file, all used vocabularies must be imported."
 $nl
 "For example, a source file containing the following code will print a parse error if you try loading it:"
 { $code "\"Hello world\" print" }
@@ -161,7 +161,7 @@ $nl
 "You would have to place the first definition after the two others for the parser to accept the file."
 { $references
     { }
-    "vocabulary-search"
+    "word-search"
     "words"
     "parser"
 } ;
@@ -286,7 +286,6 @@ ARTICLE: "cookbook-pitfalls" "Pitfalls to avoid"
 { $list
     "Factor only makes use of one native thread, and Factor threads are scheduled co-operatively. C library calls block the entire VM."
     "Factor does not hide anything from the programmer, all internals are exposed. It is your responsibility to avoid writing fragile code which depends too much on implementation detail."
-    { "When a source file uses two vocabularies which define words with the same name, the order of the vocabularies in the " { $link POSTPONE: USE: } " or " { $link POSTPONE: USING: } " forms is important. The " { $link POSTPONE: QUALIFIED: } " word implements qualified naming, which can be used to resolve ambiguities." }
     { "If a literal object appears in a word definition, the object itself is pushed on the stack when the word executes, not a copy. If you intend to mutate this object, you must " { $link clone } " it first. See " { $link "syntax-literals" } "." }
     { "For a discussion of potential issues surrounding the " { $link f } " object, see " { $link "booleans" } "." }
     { "Factor's object system is quite flexible. Careless usage of union, mixin and predicate classes can lead to similar problems to those caused by “multiple inheritance” in other languages. In particular, it is possible to have two classes such that they have a non-empty intersection and yet neither is a subclass of the other. If a generic word defines methods on two such classes, various disambiguation rules are applied to ensure method dispatch remains deterministic, however they may not be what you expect. See " { $link "method-order" } " for details." }
diff --git a/basis/help/handbook/handbook.factor b/basis/help/handbook/handbook.factor
index b83fb22ccf..a18dcd03f7 100644
--- a/basis/help/handbook/handbook.factor
+++ b/basis/help/handbook/handbook.factor
@@ -248,14 +248,14 @@ ARTICLE: "handbook-language-reference" "The language"
 { $subsection "namespaces-global" }
 { $subsection "values" }
 { $heading "Abstractions" }
-{ $subsection "errors" }
+{ $subsection "fry" }
 { $subsection "objects" }
+{ $subsection "errors" }
 { $subsection "destructors" }
-{ $subsection "continuations" }
 { $subsection "memoize" }
 { $subsection "parsing-words" }
 { $subsection "macros" }
-{ $subsection "fry" }
+{ $subsection "continuations" }
 { $heading "Program organization" }
 { $subsection "vocabs.loader" }
 "Vocabularies tagged " { $link T{ vocab-tag { name "extensions" } } } " implement various additional language abstractions." ;
diff --git a/basis/help/tutorial/tutorial.factor b/basis/help/tutorial/tutorial.factor
index 7686022b70..a46e577357 100644
--- a/basis/help/tutorial/tutorial.factor
+++ b/basis/help/tutorial/tutorial.factor
@@ -38,7 +38,7 @@ $nl
 $nl
 "Now we have changed the source file, we must reload it into Factor so that we can test the new definition. To do this, simply go to the Factor listener and press " { $command tool "common" refresh-all } ". This will find any previously-loaded source files which have changed on disk, and reload them."
 $nl
-"When you do this, you will get an error about the " { $link dup } " word not being found. This is because this word is part of the " { $vocab-link "kernel" } " vocabulary, but this vocabulary is not part of the source file's " { $link "vocabulary-search" } ". You must explicitly list dependencies in source files. This allows Factor to automatically load required vocabularies and makes larger programs easier to maintain."
+"When you do this, you will get an error about the " { $link dup } " word not being found. This is because this word is part of the " { $vocab-link "kernel" } " vocabulary, but this vocabulary is not part of the source file's " { $link "word-search" } ". You must explicitly list dependencies in source files. This allows Factor to automatically load required vocabularies and makes larger programs easier to maintain."
 $nl
 "To add the word to the search path, first convince yourself that this word is in the " { $vocab-link "kernel" } " vocabulary. Enter " { $snippet "dup" } " in the listener's input area, and press " { $operation com-browse } ". This will open the documentation browser tool, viewing the help for the " { $link dup } " word. One of the subheadings in the help article will mention the word's vocabulary."
 $nl
diff --git a/basis/html/components/components-tests.factor b/basis/html/components/components-tests.factor
index da2e5b5991..c901e35e3e 100644
--- a/basis/html/components/components-tests.factor
+++ b/basis/html/components/components-tests.factor
@@ -3,6 +3,7 @@ USING: tools.test kernel io.streams.string
 io.streams.null accessors inspector html.streams
 html.components html.forms namespaces
 xml.writer ;
+FROM: html.components => inspector ;
 
 [ ] [ begin-form ] unit-test
 
diff --git a/basis/html/forms/forms-tests.factor b/basis/html/forms/forms-tests.factor
index d2dc3ed3a3..006a435cf0 100644
--- a/basis/html/forms/forms-tests.factor
+++ b/basis/html/forms/forms-tests.factor
@@ -1,6 +1,7 @@
 IN: html.forms.tests
 USING: kernel sequences tools.test assocs html.forms validators accessors
 namespaces ;
+FROM: html.forms => values ;
 
 : with-validation ( quot -- messages )
     [
diff --git a/basis/html/streams/streams-tests.factor b/basis/html/streams/streams-tests.factor
index 835874cbb7..79e8027489 100644
--- a/basis/html/streams/streams-tests.factor
+++ b/basis/html/streams/streams-tests.factor
@@ -1,6 +1,6 @@
 USING: html.streams html.streams.private accessors io
 io.streams.string io.styles kernel namespaces tools.test
-xml.writer sbufs sequences inspector colors xml.writer
+sbufs sequences inspector colors xml.writer
 classes.predicate prettyprint ;
 IN: html.streams.tests
 
diff --git a/basis/html/templates/chloe/chloe-tests.factor b/basis/html/templates/chloe/chloe-tests.factor
index fd786d355d..8003d71d36 100644
--- a/basis/html/templates/chloe/chloe-tests.factor
+++ b/basis/html/templates/chloe/chloe-tests.factor
@@ -1,7 +1,7 @@
 USING: html.templates html.templates.chloe
 tools.test io.streams.string kernel sequences ascii boxes
 namespaces xml html.components html.forms
-splitting unicode.categories furnace accessors
+splitting furnace accessors
 html.templates.chloe.compiler ;
 IN: html.templates.chloe.tests
 
diff --git a/basis/http/http-tests.factor b/basis/http/http-tests.factor
index 5c73377cbe..f11aa9eaa2 100644
--- a/basis/http/http-tests.factor
+++ b/basis/http/http-tests.factor
@@ -173,10 +173,10 @@ Set-Cookie: oo="bar; a=b"; comment="your mom"; httponly=yes
 ] unit-test
 
 ! Live-fire exercise
-USING: http.server http.server.static furnace.sessions furnace.alloy
-furnace.actions furnace.auth furnace.auth.login furnace.db http.client
-io.servers.connection io.files io.files.temp io.directories io io.encodings.ascii
-accessors namespaces threads
+USING: http.server.static furnace.sessions furnace.alloy
+furnace.actions furnace.auth furnace.auth.login furnace.db
+io.servers.connection io.files io.files.temp io.directories io
+threads
 http.server.responses http.server.redirection furnace.redirection
 http.server.dispatchers db.tuples ;
 
diff --git a/basis/io/files/info/info-tests.factor b/basis/io/files/info/info-tests.factor
index 7b19f56b10..d494e87dd7 100644
--- a/basis/io/files/info/info-tests.factor
+++ b/basis/io/files/info/info-tests.factor
@@ -1,4 +1,4 @@
-USING: io.files.info io.pathnames io.encodings.utf8 io.files
+USING: io.files.info io.encodings.utf8 io.files
 io.directories kernel io.pathnames accessors tools.test
 sequences io.files.temp ;
 IN: io.files.info.tests
diff --git a/basis/listener/listener-tests.factor b/basis/listener/listener-tests.factor
index ccdd0be8c8..907c45360d 100644
--- a/basis/listener/listener-tests.factor
+++ b/basis/listener/listener-tests.factor
@@ -15,8 +15,6 @@ SYNTAX: hello "Hi" print ;
 ] with-file-vocabs
 
 [
-    "debugger" add-ambiguous-use
-
     [ [ \ + 1 2 3 4 ] ]
     [
         [
diff --git a/basis/lists/lazy/examples/examples-tests.factor b/basis/lists/lazy/examples/examples-tests.factor
index 04886e2c1c..f21775bd9b 100644
--- a/basis/lists/lazy/examples/examples-tests.factor
+++ b/basis/lists/lazy/examples/examples-tests.factor
@@ -1,4 +1,4 @@
-USING: lists.lazy.examples lists.lazy tools.test ;
+USING: lists.lazy.examples lists.lazy lists tools.test ;
 IN: lists.lazy.examples.tests
 
 [ { 1 3 5 7 } ] [ 4 odds ltake list>array ] unit-test
diff --git a/basis/lists/lazy/lazy-docs.factor b/basis/lists/lazy/lazy-docs.factor
index c46d3251a9..706431d0a2 100644
--- a/basis/lists/lazy/lazy-docs.factor
+++ b/basis/lists/lazy/lazy-docs.factor
@@ -93,22 +93,12 @@ HELP: luntil
 { $values { "list" "a cons object" } { "quot" { $quotation "( X -- ? )" } } { "result" "resulting cons object" } }
 { $description "Outputs a lazy list containing the first items in the list until after " { $snippet "quot" } " evaluates to t. No evaluation of the list elements occurs initially but a " { $link <lazy-while> } " object is returned with conforms to the list protocol. Calling " { $link car } ", " { $link cdr } " or " { $link nil? } " on this will evaluate elements as required." } ;
 
-HELP: list>vector
-{ $values { "list" "a cons object" } { "vector" "the list converted to a vector" } }
-{ $description "Convert a list to a vector. If the list is a lazy infinite list then this will enter an infinite loop." } 
-{ $see-also list>array } ;
-
-HELP: list>array
-{ $values { "list" "a cons object" } { "array" "the list converted to an array" } }
-{ $description "Convert a list to an array. If the list is a lazy infinite list then this will enter an infinite loop." } 
-{ $see-also list>vector } ;
-
 HELP: lappend
 { $values { "list1" "a cons object" } { "list2" "a cons object" } { "result" "a lazy list of list2 appended to list1" } }
 { $description "Perform a similar functionality to that of the " { $link append } " word, but in a lazy manner. No evaluation of the list elements occurs initially but a " { $link <lazy-append> } " object is returned which conforms to the list protocol. Calling " { $link car } ", " { $link cdr } " or " { $link nil? } " on this will evaluate elements as required. Successive calls to " { $link cdr } " will iterate through list1, followed by list2." } ;
 
 HELP: lfrom-by
-{ $values { "n" "an integer" } { "quot" { $quotation "( -- int )" } } { "lazy-from-by" "a lazy list of integers" } }
+{ $values { "n" "an integer" } { "quot" { $quotation "( -- n )" } } { "lazy-from-by" "a lazy list of integers" } }
 { $description "Return an infinite lazy list of values starting from n, with each successive value being the result of applying quot to n." } ;
 
 HELP: lfrom
@@ -117,7 +107,7 @@ HELP: lfrom
 
 HELP: seq>list
 { $values { "index" "an integer 0 or greater" } { "seq" "a sequence" } { "list" "a list" } }
-{ $description "Convert the sequence into a list, starting from the 'index' offset into the sequence." } 
+{ $description "Convert the sequence into a list, starting from " { $snippet "index" } "." }
 { $see-also >list } ;
 
 HELP: >list
@@ -154,7 +144,7 @@ HELP: lmerge
 { $values { "list1" "a list" } { "list2" "a list" } { "result" "lazy list merging list1 and list2" } }
 { $description "Return the result of merging the two lists in a lazy manner." } 
 { $examples
-  { $example "USING: lists.lazy prettyprint ;" "{ 1 2 3 } >list { 4 5 6 } >list lmerge list>array ." "{ 1 4 2 5 3 6 }" }
+  { $example "USING: lists lists.lazy prettyprint ;" "{ 1 2 3 } >list { 4 5 6 } >list lmerge list>array ." "{ 1 4 2 5 3 6 }" }
 } ;
 
 HELP: lcontents
diff --git a/basis/lists/lazy/lazy.factor b/basis/lists/lazy/lazy.factor
index 64a3f099a0..49aee471bf 100644
--- a/basis/lists/lazy/lazy.factor
+++ b/basis/lists/lazy/lazy.factor
@@ -178,12 +178,6 @@ M: lazy-filter nil? ( lazy-filter -- bool )
         ] if
     ] if ;
 
-: list>vector ( list -- vector )
-    [ [ , ] leach ] V{ } make ;
-
-: list>array ( list -- array )
-    [ [ , ] leach ] { } make ;
-
 TUPLE: lazy-append list1 list2 ;
 
 C: <lazy-append> lazy-append
diff --git a/basis/lists/lists-docs.factor b/basis/lists/lists-docs.factor
index 8782c3d9b4..3fac05affe 100644
--- a/basis/lists/lists-docs.factor
+++ b/basis/lists/lists-docs.factor
@@ -54,21 +54,21 @@ ARTICLE: { "lists" "manipulation" } "Manipulating lists"
 { $subsection lcut } ;
 
 HELP: cons 
-{ $values { "car" "the head of the list cell" } { "cdr" "the tail of the list cell" } { "cons" "a cons object" } }
+{ $values { "car" "the head of the list cell" } { "cdr" "the tail of the list cell" } { "cons" list } }
 { $description "Constructs a cons cell." } ;
 
 HELP: swons 
-{ $values { "cdr" "the tail of the list cell" } { "car" "the head of the list cell" } { "cons" "a cons object" } }
+{ $values { "cdr" "the tail of the list cell" } { "car" "the head of the list cell" } { "cons" list } }
 { $description "Constructs a cons cell." } ;
 
 { cons swons uncons unswons } related-words
 
 HELP: car
-{ $values { "cons" "a cons object" } { "car" "the first item in the list" } }
+{ $values { "cons" list } { "car" "the first item in the list" } }
 { $description "Returns the first item in the list." } ;
 
 HELP: cdr
-{ $values { "cons" "a cons object" } { "cdr" "a cons object" } }
+{ $values { "cons" list } { "cdr" list } }
 { $description "Returns the tail of the list." } ;
 
 { car cdr } related-words
@@ -86,51 +86,51 @@ HELP: nil?
 { 1list 2list 3list } related-words
 
 HELP: 1list
-{ $values { "obj" "an object" } { "cons" "a cons object" } }
+{ $values { "obj" "an object" } { "cons" list } }
 { $description "Create a list with 1 element." } ;
 
 HELP: 2list
-{ $values { "a" "an object" } { "b" "an object" } { "cons" "a cons object" } }
+{ $values { "a" "an object" } { "b" "an object" } { "cons" list } }
 { $description "Create a list with 2 elements." } ;
 
 HELP: 3list
-{ $values { "a" "an object" } { "b" "an object" } { "c" "an object" } { "cons" "a cons object" } }
+{ $values { "a" "an object" } { "b" "an object" } { "c" "an object" } { "cons" list } }
 { $description "Create a list with 3 elements." } ;
 
 HELP: lnth
-{ $values { "n" "an integer index" } { "list" "a cons object" } { "elt" "the element at the nth index" } }
+{ $values { "n" "an integer index" } { "list" list } { "elt" "the element at the nth index" } }
 { $description "Outputs the nth element of the list." } 
 { $see-also llength cons car cdr } ;
 
 HELP: llength
-{ $values { "list" "a cons object" } { "n" "a non-negative integer" } }
+{ $values { "list" list } { "n" "a non-negative integer" } }
 { $description "Outputs the length of the list. This should not be called on an infinite list." } 
 { $see-also lnth cons car cdr } ;
 
 HELP: uncons
-{ $values { "cons" "a cons object" } { "car" "the head of the list" } { "cdr" "the tail of the list" } }
+{ $values { "cons" list } { "car" "the head of the list" } { "cdr" "the tail of the list" } }
 { $description "Put the head and tail of the list on the stack." } ;
 
 HELP: unswons
-{ $values { "cons" "a cons object" } { "car" "the head of the list" } { "cdr" "the tail of the list" } }
+{ $values { "cons" list } { "car" "the head of the list" } { "cdr" "the tail of the list" } }
 { $description "Put the head and tail of the list on the stack." } ;
 
 { leach foldl lmap>array } related-words
 
 HELP: leach
-{ $values { "list" "a cons object" } { "quot" { $quotation "( obj -- )" } } }
+{ $values { "list" list } { "quot" { $quotation "( obj -- )" } } }
 { $description "Call the quotation for each item in the list." } ;
 
 HELP: foldl
-{ $values { "list" "a cons object" } { "identity" "an object" } { "quot" { $quotation "( prev elt -- next )" } } { "result" "the final result" } }
+{ $values { "list" list } { "identity" "an object" } { "quot" { $quotation "( prev elt -- next )" } } { "result" "the final result" } }
 { $description "Combines successive elements of the list (in a left-assocative order) using a binary operation and outputs the final result." } ;
 
 HELP: foldr
-{ $values { "list" "a cons object" } { "identity" "an object" } { "quot" { $quotation "( prev elt -- next )" } } { "result" "the final result" } }
+{ $values { "list" list } { "identity" "an object" } { "quot" { $quotation "( prev elt -- next )" } } { "result" "the final result" } }
 { $description "Combines successive elements of the list (in a right-assocative order) using a binary operation, and outputs the final result." } ;
 
 HELP: lmap
-{ $values { "list" "a cons object" } { "quot" { $quotation "( old -- new )" } } { "result" "the final result" } }
+{ $values { "list" list } { "quot" { $quotation "( old -- new )" } } { "result" "the final result" } }
 { $description "Applies the quotation to each element of the list in order, collecting the new elements into a new list." } ;
 
 HELP: lreverse
@@ -138,23 +138,15 @@ HELP: lreverse
 { $description "Reverses the input list, outputing a new, reversed list. The output is a strict cons list." } ;
 
 HELP: list>array    
-{ $values { "list" "a cons object" } { "array" array } }
-{ $description "Turns the given cons object into an array, maintaing order." } ;
-
-HELP: sequence>cons
-{ $values { "sequence" sequence } { "list" cons } }
-{ $description "Turns the given array into a cons object, maintaing order." } ;
+{ $values { "list" list } { "array" array } }
+{ $description "Convert a list into an array." } ;
 
 HELP: deep-list>array
 { $values { "list" list } { "array" array } }
-{ $description "Recursively turns the given cons object into an array, maintaing order and also converting nested lists." } ;
-
-HELP: deep-sequence>cons
-{ $values { "sequence" sequence } { "cons" cons } }
-{ $description "Recursively turns the given sequence into a cons object, maintaing order and also converting nested lists." } ;
+{ $description "Recursively turns the given cons object into an array, maintaining order and also converting nested lists." } ;
 
 HELP: traverse    
-{ $values { "list"  "a cons object" } { "pred" { $quotation "( list/elt -- ? )" } }
+{ $values { "list"  list } { "pred" { $quotation "( list/elt -- ? )" } }
           { "quot" { $quotation "( list/elt -- result)" } }  { "result" "a new cons object" } }
 { $description "Recursively traverses the list object, replacing any elements (which can themselves be sublists) that pred" 
  " returns true for with the result of applying quot to." } ;
diff --git a/basis/lists/lists-tests.factor b/basis/lists/lists-tests.factor
index 13d2e03e0f..69daa39e41 100644
--- a/basis/lists/lists-tests.factor
+++ b/basis/lists/lists-tests.factor
@@ -1,6 +1,6 @@
 ! Copyright (C) 2008 James Cash
 ! See http://factorcode.org/license.txt for BSD license.
-USING: tools.test lists math kernel ;
+USING: tools.test lists lists.lazy math kernel ;
 IN: lists.tests
 
 { { 3 4 5 6 7 } } [
@@ -23,49 +23,24 @@ IN: lists.tests
                 +nil+ } } } } 0 [ + ] foldl
 ] unit-test
     
-{ T{ cons f
-      1
-      T{ cons f
-          2
-          T{ cons f
-              T{ cons f
-                  3
-                  T{ cons f
-                      4
-                      T{ cons f
-                          T{ cons f 5 +nil+ }
-                          +nil+ } } }
-          +nil+ } } }
-} [
-    { 1 2 { 3 4 { 5 } } } deep-sequence>cons
-] unit-test
-    
-{ { 1 2 { 3 4 { 5 } } } } [
-  { 1 2 { 3 4 { 5 } } } deep-sequence>cons deep-list>array
-] unit-test
-    
 { T{ cons f 2 T{ cons f 3 T{ cons f 4 T{ cons f 5 +nil+ } } } } } [
-    { 1 2 3 4 } sequence>cons [ 1+ ] lmap
+    { 1 2 3 4 } seq>list [ 1+ ] lmap
 ] unit-test
     
 { 15 } [
- { 1 2 3 4 5 } sequence>cons 0 [ + ] foldr
+ { 1 2 3 4 5 } seq>list 0 [ + ] foldr
 ] unit-test
     
 { { 5 4 3 2 1 } } [
-    { 1 2 3 4 5 } sequence>cons lreverse list>array
+    { 1 2 3 4 5 } seq>list lreverse list>array
 ] unit-test
     
 { 5 } [
-    { 1 2 3 4 5 } sequence>cons llength
-] unit-test
-    
-{ { 3 4 { 5 6 { 7 } } } } [
-  { 1 2 { 3 4 { 5 } } } deep-sequence>cons [ atom? ] [ 2 + ] traverse deep-list>array
+    { 1 2 3 4 5 } seq>list llength
 ] unit-test
     
 { { 1 2 3 4 5 6 } } [
-    { 1 2 3 } sequence>cons { 4 5 6 } sequence>cons lappend list>array
+    { 1 2 3 } seq>list { 4 5 6 } seq>list lappend list>array
 ] unit-test
 
-[ { 1 } { 2 } ] [ { 1 2 } sequence>cons 1 lcut [ list>array ] bi@ ] unit-test
+[ { 1 } { 2 } ] [ { 1 2 } seq>list 1 lcut [ list>array ] bi@ ] unit-test
diff --git a/basis/literals/literals-docs.factor b/basis/literals/literals-docs.factor
index 9dd398d962..9ec8e30133 100644
--- a/basis/literals/literals-docs.factor
+++ b/basis/literals/literals-docs.factor
@@ -65,7 +65,7 @@ ${ five six 7 } .
 ARTICLE: "literals" "Interpolating code results into literal values"
 "The " { $vocab-link "literals" } " vocabulary contains words to run code at parse time and insert the results into more complex literal values."
 { $example <"
-USING: kernel literals math prettyprint ;
+USE: literals
 IN: scratchpad
 
 CONSTANT: five 5
diff --git a/basis/math/complex/complex-docs.factor b/basis/math/complex/complex-docs.factor
index a51b86ff0b..9cb80447e5 100644
--- a/basis/math/complex/complex-docs.factor
+++ b/basis/math/complex/complex-docs.factor
@@ -4,9 +4,9 @@ IN: math.complex
 
 ARTICLE: "complex-numbers-zero" "Embedding of real numbers in complex numbers"
 "Constructing a complex number with an imaginary component equal to an integer zero simply returns the real number corresponding to the real component:"
-{ $example "USING: math prettyprint ;" "C{ 1 2 } C{ 3 -2 } + ." "4" }
+{ $example "C{ 1 2 } C{ 3 -2 } + ." "4" }
 "Constructing a complex number with an imaginary component equal to floating point zero will still output a new complex number, however:"
-{ $example "USING: math prettyprint ;" "C{ 0.0 2.0 } C{ 0.0 1.0 } * ." "C{ -2.0 0.0 }" }
+{ $example "C{ 0.0 2.0 } C{ 0.0 1.0 } * ." "C{ -2.0 0.0 }" }
 "Unlike math, where all real numbers are also complex numbers, Factor only considers a number to be a complex number if its imaginary part is non-zero. However, complex number operations are fully supported for real numbers; they are treated as having an imaginary part of zero." ;
 
 ARTICLE: "complex-numbers" "Complex numbers"
diff --git a/basis/opengl/textures/textures-tests.factor b/basis/opengl/textures/textures-tests.factor
index 3efdb43cd8..24f43c52ac 100644
--- a/basis/opengl/textures/textures-tests.factor
+++ b/basis/opengl/textures/textures-tests.factor
@@ -1,8 +1,7 @@
 ! Copyright (C) 2009 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: tools.test opengl.textures opengl.textures.private
-opengl.textures.private images kernel namespaces accessors
-sequences ;
+images kernel namespaces accessors sequences ;
 IN: opengl.textures.tests
 
 [
diff --git a/basis/peg/ebnf/ebnf.factor b/basis/peg/ebnf/ebnf.factor
index d4ad62fbea..f3d555d5a1 100644
--- a/basis/peg/ebnf/ebnf.factor
+++ b/basis/peg/ebnf/ebnf.factor
@@ -461,7 +461,7 @@ M: ebnf-sequence build-locals ( code ast -- code )
 
 M: ebnf-var build-locals ( code ast -- )
   [
-    "FROM: locals => [let* ; FROM: kernel => dup ; [let* | " %
+    "FROM: locals => [let* ; FROM: kernel => dup nip ; [let* | " %
     name>> % " [ dup ] " %
     " | " %
     %  
diff --git a/basis/peg/peg-tests.factor b/basis/peg/peg-tests.factor
index cae1e05dc8..501b8ed856 100644
--- a/basis/peg/peg-tests.factor
+++ b/basis/peg/peg-tests.factor
@@ -2,7 +2,7 @@
 ! See http://factorcode.org/license.txt for BSD license.
 !
 USING: kernel tools.test strings namespaces make arrays sequences 
-       peg peg.private peg.parsers accessors words math accessors ;
+       peg peg.private peg.parsers words math accessors ;
 IN: peg.tests
 
 [ ] [ reset-pegs ] unit-test
diff --git a/basis/prettyprint/prettyprint-tests.factor b/basis/prettyprint/prettyprint-tests.factor
index 25ee83985e..cd10278760 100644
--- a/basis/prettyprint/prettyprint-tests.factor
+++ b/basis/prettyprint/prettyprint-tests.factor
@@ -91,15 +91,13 @@ unit-test
 
 : check-see ( expect name -- ? )
     [
-        use [ clone ] change
-
         [
             [ parse-fresh drop ] with-compilation-unit
             [
                 "prettyprint.tests" lookup see
             ] with-string-writer "\n" split but-last
         ] keep =
-    ] with-scope ;
+    ] with-interactive-vocabs ;
 
 GENERIC: method-layout ( a -- b )
 
diff --git a/basis/regexp/regexp-docs.factor b/basis/regexp/regexp-docs.factor
index 2ff31f0cec..3eb4e8a9bf 100644
--- a/basis/regexp/regexp-docs.factor
+++ b/basis/regexp/regexp-docs.factor
@@ -31,7 +31,7 @@ ARTICLE: { "regexp" "intro" } "A quick introduction to regular expressions"
 "To search a file for all lines that match a given regular expression, you could use code like this:"
 { $code <" "file.txt" ascii file-lines [ R/ (f|b)oo+/ re-contains? ] filter "> }
 "To test if a string in its entirety matches a regular expression, the following can be used:"
-{ $example <" USING: regexp prettyprint ; "fooo" R/ (b|f)oo+/ matches? . "> "t" }
+{ $example <" USE: regexp "fooo" R/ (b|f)oo+/ matches? . "> "t" }
 "Regular expressions can't be used for all parsing tasks. For example, they are not powerful enough to match balancing parentheses." ;
 
 ARTICLE: { "regexp" "construction" } "Constructing regular expressions"
diff --git a/basis/serialize/serialize-tests.factor b/basis/serialize/serialize-tests.factor
index d23c8be84b..b6a4b1a86f 100644
--- a/basis/serialize/serialize-tests.factor
+++ b/basis/serialize/serialize-tests.factor
@@ -1,7 +1,7 @@
 ! Copyright (C) 2006 Chris Double.
 ! See http://factorcode.org/license.txt for BSD license.
 ! 
-USING: tools.test kernel serialize io io.streams.byte-array math
+USING: tools.test kernel serialize io io.streams.byte-array
 alien arrays byte-arrays bit-arrays specialized-arrays.double
 sequences math prettyprint parser classes math.constants
 io.encodings.binary random assocs serialize.private ;
diff --git a/basis/stack-checker/call-effect/call-effect-tests.factor b/basis/stack-checker/call-effect/call-effect-tests.factor
index b222cbbcf7..0ad64cace3 100644
--- a/basis/stack-checker/call-effect/call-effect-tests.factor
+++ b/basis/stack-checker/call-effect/call-effect-tests.factor
@@ -1,4 +1,4 @@
-USING: stack-checker.call-effect tools.test math kernel math effects ;
+USING: stack-checker.call-effect tools.test kernel math effects ;
 IN: stack-checker.call-effect.tests
 
 [ t ] [ \ + (( a b -- c )) execute-effect-unsafe? ] unit-test
diff --git a/basis/struct-arrays/struct-arrays-tests.factor b/basis/struct-arrays/struct-arrays-tests.factor
index a8ce98888c..8ce45ccc15 100755
--- a/basis/struct-arrays/struct-arrays-tests.factor
+++ b/basis/struct-arrays/struct-arrays-tests.factor
@@ -1,7 +1,6 @@
 IN: struct-arrays.tests
 USING: struct-arrays tools.test kernel math sequences
-alien.syntax alien.c-types destructors libc accessors
-destructors ;
+alien.syntax alien.c-types destructors libc accessors ;
 
 C-STRUCT: test-struct
 { "int" "x" }
diff --git a/basis/ui/gadgets/gadgets-tests.factor b/basis/ui/gadgets/gadgets-tests.factor
index 77860ba5b5..ade5c8101e 100644
--- a/basis/ui/gadgets/gadgets-tests.factor
+++ b/basis/ui/gadgets/gadgets-tests.factor
@@ -1,8 +1,7 @@
-USING: accessors ui.gadgets ui.gadgets.private ui.gadgets.packs
-ui.gadgets.worlds tools.test namespaces models kernel dlists deques
-math sets math.parser ui sequences hashtables assocs io arrays
-prettyprint io.streams.string math.rectangles ui.gadgets.private
-sets generic ;
+USING: accessors ui.gadgets ui.gadgets.packs ui.gadgets.worlds
+tools.test namespaces models kernel dlists deques math
+math.parser ui sequences hashtables assocs io arrays prettyprint
+io.streams.string math.rectangles ui.gadgets.private sets generic ;
 IN: ui.gadgets.tests
 
 [ { 300 300 } ]
diff --git a/basis/ui/tools/listener/listener-tests.factor b/basis/ui/tools/listener/listener-tests.factor
index e06e17374f..fbbac8f3fa 100644
--- a/basis/ui/tools/listener/listener-tests.factor
+++ b/basis/ui/tools/listener/listener-tests.factor
@@ -2,7 +2,7 @@ USING: continuations documents
 ui.tools.listener hashtables kernel namespaces parser sequences
 tools.test ui.commands ui.gadgets ui.gadgets.editors
 ui.gadgets.panes vocabs words ui.gadgets.debug slots.private
-threads arrays generic threads accessors listener math
+arrays generic threads accessors listener math
 calendar concurrency.promises io ui.tools.common ;
 IN: ui.tools.listener.tests
 
@@ -146,7 +146,7 @@ CONSTANT: text "Hello world.\nThis is a test."
     [ ] [ "listener" get com-end ] unit-test
 ] with-grafted-gadget
 
-[ ] [ \ + <interactor> vocabs>> use-if-necessary ] unit-test
+[ ] [ \ + <interactor> manifest>> use-if-necessary ] unit-test
 
 [ ] [ <listener-gadget> "l" set ] unit-test
 [ ] [ "l" get com-scroll-up ] unit-test
diff --git a/basis/xml/syntax/syntax-docs.factor b/basis/xml/syntax/syntax-docs.factor
index 34473fecfc..0f04f1b7b2 100644
--- a/basis/xml/syntax/syntax-docs.factor
+++ b/basis/xml/syntax/syntax-docs.factor
@@ -50,7 +50,7 @@ ARTICLE: { "xml.syntax" "interpolation" } "XML interpolation syntax"
 $nl
 "These forms can be used where a tag might go, as in " { $snippet "[XML <foo><-></foo> XML]" } " or where an attribute might go, as in " { $snippet "[XML <foo bar=<->/> XML]" } ". When an attribute is spliced in, it is not included if the value is " { $snippet "f" } " and if the value is not a string, the value is put through " { $link present } ". Here is an example of the fry style of XML interpolation:"
 { $example 
-{" USING: splitting sequences xml.writer xml.syntax ;
+{" USING: splitting xml.writer xml.syntax ;
 "one two three" " " split
 [ [XML <item><-></item> XML] ] map
 <XML <doc><-></doc> XML> pprint-xml"}
@@ -86,7 +86,7 @@ $nl
 {" <?xml version="1.0" encoding="UTF-8"?>
 <x number="3" url="http://factorcode.org/" string="hello" word="drop"/>"} }
 "XML interpolation can also be used, in conjunction with " { $vocab-link "inverse" } " in pattern matching. For example:"
-{ $example {" USING: sequences xml.syntax inverse ;
+{ $example {" USING: xml.syntax inverse ;
 : dispatch ( xml -- string )
     {
         { [ [XML <a><-></a> XML] ] [ "a" prepend ] }
diff --git a/basis/xml/syntax/syntax-tests.factor b/basis/xml/syntax/syntax-tests.factor
index 6fcaf780cc..06ba2028a6 100644
--- a/basis/xml/syntax/syntax-tests.factor
+++ b/basis/xml/syntax/syntax-tests.factor
@@ -100,8 +100,6 @@ XML-NS: foo http://blah.com
 
 [ "" ] [ [XML XML] concat ] unit-test
 
-USE: inverse
-
 [ "foo" ] [ [XML <a>foo</a> XML] [ [XML <a><-></a> XML] ] undo ] unit-test
 [ "foo" ] [ [XML <a bar='foo'/> XML] [ [XML <a bar=<-> /> XML] ] undo ] unit-test
 [ "foo" "baz" ] [ [XML <a bar='foo'>baz</a> XML] [ [XML <a bar=<->><-></a> XML] ] undo ] unit-test
diff --git a/core/assocs/assocs-docs.factor b/core/assocs/assocs-docs.factor
index d4046a4dcf..e56fedbd26 100755
--- a/core/assocs/assocs-docs.factor
+++ b/core/assocs/assocs-docs.factor
@@ -21,7 +21,7 @@ ARTICLE: "enums" "Enumerations"
 { $subsection enum }
 { $subsection <enum> }
 "Inverting a permutation using enumerations:"
-{ $example "USING: assocs sorting prettyprint ;" "IN: scratchpad" ": invert ( perm -- perm' )" "    <enum> >alist sort-values keys ;" "{ 2 0 4 1 3 } invert ." "{ 1 3 0 4 2 }" } ;
+{ $example "IN: scratchpad" ": invert ( perm -- perm' )" "    <enum> >alist sort-values keys ;" "{ 2 0 4 1 3 } invert ." "{ 1 3 0 4 2 }" } ;
 
 HELP: enum
 { $class-description "An associative structure which wraps a sequence and maps integers to the corresponding elements of the sequence."
diff --git a/core/bootstrap/syntax.factor b/core/bootstrap/syntax.factor
index 55b92df215..f5182a0210 100644
--- a/core/bootstrap/syntax.factor
+++ b/core/bootstrap/syntax.factor
@@ -51,6 +51,7 @@ IN: bootstrap.syntax
     "UNION:"
     "INTERSECTION:"
     "USE:"
+    "UNUSE:"
     "USING:"
     "QUALIFIED:"
     "QUALIFIED-WITH:"
diff --git a/core/classes/algebra/algebra-tests.factor b/core/classes/algebra/algebra-tests.factor
index 3069c4b555..a1e83ff72c 100644
--- a/core/classes/algebra/algebra-tests.factor
+++ b/core/classes/algebra/algebra-tests.factor
@@ -1,6 +1,6 @@
 USING: alien arrays definitions generic assocs hashtables io
 kernel math namespaces parser prettyprint sequences strings
-tools.test vectors words quotations classes classes.algebra
+tools.test words quotations classes classes.algebra
 classes.private classes.union classes.mixin classes.predicate
 vectors definitions source-files compiler.units growable
 random stack-checker effects kernel.private sbufs math.order
diff --git a/core/classes/classes-tests.factor b/core/classes/classes-tests.factor
index 61d153f064..d7fba97977 100644
--- a/core/classes/classes-tests.factor
+++ b/core/classes/classes-tests.factor
@@ -1,4 +1,4 @@
-USING: alien arrays definitions generic assocs hashtables io
+USING: alien arrays generic assocs hashtables io
 io.streams.string kernel math namespaces parser prettyprint
 sequences strings tools.test vectors words quotations classes
 classes.private classes.union classes.mixin classes.predicate
diff --git a/core/classes/mixin/mixin-tests.factor b/core/classes/mixin/mixin-tests.factor
index f44642fdd5..a9a7952c51 100644
--- a/core/classes/mixin/mixin-tests.factor
+++ b/core/classes/mixin/mixin-tests.factor
@@ -1,9 +1,8 @@
-USING: alien arrays definitions generic assocs hashtables io
-kernel math namespaces parser prettyprint sequences strings
-tools.test vectors words quotations classes
-classes.private classes.union classes.mixin classes.predicate
-classes.algebra vectors definitions source-files
-compiler.units kernel.private sorting vocabs eval ;
+USING: alien arrays definitions generic assocs hashtables io kernel
+math namespaces parser prettyprint sequences strings tools.test words
+quotations classes classes.private classes.union classes.mixin
+classes.predicate classes.algebra vectors source-files compiler.units
+kernel.private sorting vocabs eval ;
 IN: classes.mixin.tests
 
 ! Test mixins
diff --git a/core/classes/predicate/predicate-tests.factor b/core/classes/predicate/predicate-tests.factor
index 80613f4f2e..951608931b 100644
--- a/core/classes/predicate/predicate-tests.factor
+++ b/core/classes/predicate/predicate-tests.factor
@@ -29,6 +29,6 @@ PREDICATE: tuple-c < tuple-b slot>> ;
 
 GENERIC: ptest ( tuple -- )
 M: tuple-a ptest drop ;
-IN: classes.predicate.tests USING: kernel ; M: tuple-c ptest drop ;
+M: tuple-c ptest drop ;
 
 [ ] [ tuple-b new ptest ] unit-test
diff --git a/core/combinators/combinators-docs.factor b/core/combinators/combinators-docs.factor
index 1a17e8c1fb..72602c25b9 100755
--- a/core/combinators/combinators-docs.factor
+++ b/core/combinators/combinators-docs.factor
@@ -152,7 +152,6 @@ ARTICLE: "compositional-examples" "Examples of compositional combinator usage"
 { $code ": subtract-n ( seq n -- seq' ) swap [ over - ] map nip ;" }
 "Three shuffle words are required to pass the value around. Instead, the loop-invariant value can be partially applied to a quotation using " { $link curry } ", yielding a new quotation that is passed to " { $link map } ":"
 { $example
-  "USING: kernel math prettyprint sequences ;"
   ": subtract-n ( seq n -- seq' ) [ - ] curry map ;"
   "{ 10 20 30 } 5 subtract-n ."
   "{ 5 15 25 }"
@@ -163,7 +162,6 @@ $nl
 { $code ": n-subtract ( n seq -- seq' ) swap [ swap - ] curry map ;" }
 "Since this pattern comes up often, " { $link with } " encapsulates it:"
 { $example
-  "USING: kernel math prettyprint sequences ;"
   ": n-subtract ( n seq -- seq' ) [ - ] with map ;"
   "30 { 10 20 30 } n-subtract ."
   "{ 20 10 0 }"
diff --git a/core/make/make-docs.factor b/core/make/make-docs.factor
index d3ec6c3e57..7808872588 100644
--- a/core/make/make-docs.factor
+++ b/core/make/make-docs.factor
@@ -48,7 +48,7 @@ $nl
 "The accumulator sequence can be accessed directly from inside a " { $link make } ":"
 { $subsection building }
 { $example
-  "USING: make math.parser io ;"
+  "USING: make math.parser ;"
   "[ \"Language #\" % CHAR: \\s , 5 # ] \"\" make print"
   "Language # 5"
 }
diff --git a/core/parser/parser-docs.factor b/core/parser/parser-docs.factor
index d6c69f08c2..ea6a136b95 100644
--- a/core/parser/parser-docs.factor
+++ b/core/parser/parser-docs.factor
@@ -1,7 +1,7 @@
 USING: help.markup help.syntax kernel sequences words
 math strings vectors quotations generic effects classes
 vocabs.loader definitions io vocabs source-files
-quotations namespaces compiler.units assocs lexer
+namespaces compiler.units assocs lexer
 words.symbol words.alias words.constant vocabs.parser ;
 IN: parser
 
@@ -70,7 +70,8 @@ $nl
 { $subsection "reading-ahead" }
 { $subsection "parsing-word-nest" }
 { $subsection "defining-words" }
-{ $subsection "parsing-tokens" } ;
+{ $subsection "parsing-tokens" }
+{ $subsection "word-search-parsing" } ;
 
 ARTICLE: "parser-files" "Parsing source files"
 "The parser can run source files:"
@@ -84,7 +85,7 @@ $nl
 ARTICLE: "top-level-forms" "Top level forms"
 "Any code outside of a definition is known as a " { $emphasis "top-level form" } "; top-level forms are run after the entire source file has been parsed, regardless of their position in the file."
 $nl
-"Top-level forms do not have access to the " { $link in } " and " { $link use } " variables that were set at parse time, nor do they run inside " { $link with-compilation-unit } "; so meta-programming might require extra work in a top-level form compared with a parsing word."
+"Top-level forms cannot access the parse-time manifest (" { $link "word-search-parsing" } "), nor do they run inside " { $link with-compilation-unit } "; as a result, meta-programming might require extra work in a top-level form compared with a parsing word."
 $nl
 "Also, top-level forms run in a new dynamic scope, so using " { $link set } " to store values is almost always wrong, since the values will be lost after the top-level form completes. To save values computed by a top-level form, either use " { $link set-global } " or define a new word with the value." ;
 
@@ -119,8 +120,6 @@ HELP: parser-notes?
 HELP: bad-number
 { $error-description "Indicates the parser encountered an invalid numeric literal." } ;
 
-{ use in add-use (add-use) set-use set-in POSTPONE: USING: POSTPONE: USE: with-file-vocabs with-interactive-vocabs } related-words
-
 HELP: create-in
 { $values { "str" "a word name" } { "word" "a new word" } }
 { $description "Creates a word in the current vocabulary. Until re-defined, the word throws an error when invoked." }
@@ -247,4 +246,4 @@ HELP: staging-violation
 
 HELP: auto-use?
 { $var-description "If set to a true value, the behavior of the parser when encountering an unknown word name is changed. If only one loaded vocabulary has a word with this name, instead of throwing an error, the parser adds the vocabulary to the search path and prints a parse note. Off by default." }
-{ $notes "This feature is intended to help during development. To generate a " { $link POSTPONE: USING: } " form automatically, enable " { $link auto-use? } ", load the source file, and copy and paste the " { $link POSTPONE: USING: } " form printed by the parser back into the file, then disable " { $link auto-use? } ". See " { $link "vocabulary-search-errors" } "." } ;
+{ $notes "This feature is intended to help during development. To generate a " { $link POSTPONE: USING: } " form automatically, enable " { $link auto-use? } ", load the source file, and copy and paste the " { $link POSTPONE: USING: } " form printed by the parser back into the file, then disable " { $link auto-use? } ". See " { $link "word-search-errors" } "." } ;
diff --git a/core/parser/parser-tests.factor b/core/parser/parser-tests.factor
index 4474ed45c4..16f08d474a 100644
--- a/core/parser/parser-tests.factor
+++ b/core/parser/parser-tests.factor
@@ -87,18 +87,6 @@ IN: parser.tests
     [ "OCT: 999" eval( -- obj ) ] must-fail
     [ "BIN: --0" eval( -- obj ) ] must-fail
 
-    ! Another funny bug
-    [ t ] [
-        [
-            "scratchpad" in set
-            { "scratchpad" "arrays" } set-use
-            [
-                ! This shouldn't modify in/use in the outer scope!
-            ] with-file-vocabs
-
-            use get { "scratchpad" "arrays" } set-use use get =
-        ] with-scope
-    ] unit-test
     DEFER: foo
 
     "IN: parser.tests USING: math prettyprint ; SYNTAX: foo 2 2 + . ;" eval( -- )
@@ -596,7 +584,7 @@ EXCLUDE: qualified.tests.bar => x ;
 ] unit-test
 
 [ [ ] ] [
-    "IN: parser.tests.forward-ref-3 USING: parser.tests.forward-ref-1 parser.tests.forward-ref-2 ; : z ( -- ) x y ;"
+    "IN: parser.tests.forward-ref-3 FROM: parser.tests.forward-ref-1 => x y ; FROM: parser.tests.forward-ref-2 => x y ; : z ( -- ) x y ;"
     <string-reader> "forward-ref-3" parse-stream
 ] unit-test
 
@@ -605,7 +593,7 @@ EXCLUDE: qualified.tests.bar => x ;
 ] unit-test
 
 [ [ ] ] [
-    "USING: parser.tests.forward-ref-1 parser.tests.forward-ref-2 ; IN: parser.tests.forward-ref-3 : x ( -- ) ; : z ( -- ) x y ;"
+    "FROM: parser.tests.forward-ref-1 => x y ; FROM: parser.tests.forward-ref-2 => x y ; IN: parser.tests.forward-ref-3 : x ( -- ) ; : z ( -- ) x y ;"
     <string-reader> "forward-ref-3" parse-stream
 ] unit-test
 
@@ -614,7 +602,7 @@ EXCLUDE: qualified.tests.bar => x ;
 ] unit-test
 
 [ [ ] ] [
-    "IN: parser.tests.forward-ref-3 USING: parser.tests.forward-ref-1 parser.tests.forward-ref-2 ; : z ( -- ) x y ;"
+    "IN: parser.tests.forward-ref-3 FROM: parser.tests.forward-ref-1 => x y ; FROM: parser.tests.forward-ref-2 => x y ; : z ( -- ) x y ;"
     <string-reader> "forward-ref-3" parse-stream
 ] unit-test
 
diff --git a/core/syntax/syntax-docs.factor b/core/syntax/syntax-docs.factor
index fff355fb95..cd5a325b52 100644
--- a/core/syntax/syntax-docs.factor
+++ b/core/syntax/syntax-docs.factor
@@ -1,7 +1,8 @@
 USING: generic help.syntax help.markup kernel math parser words
 effects classes generic.standard classes.tuple generic.math
 generic.standard generic.single arrays io.pathnames vocabs.loader io
-sequences assocs words.symbol words.alias words.constant combinators ;
+sequences assocs words.symbol words.alias words.constant combinators 
+vocabs.parser ;
 IN: syntax
 
 ARTICLE: "parser-algorithm" "Parser algorithm"
@@ -179,7 +180,7 @@ $nl
 ARTICLE: "syntax" "Syntax"
 "Factor has two main forms of syntax: " { $emphasis "definition" } " syntax and " { $emphasis "literal" } " syntax. Code is data, so the syntax for code is a special case of object literal syntax. This section documents literal syntax. Definition syntax is covered in " { $link "words" } ". Extending the parser is the main topic of " { $link "parser" } "."
 { $subsection "parser-algorithm" }
-{ $subsection "vocabulary-search" }
+{ $subsection "word-search" }
 { $subsection "top-level-forms" }
 { $subsection "syntax-comments" }
 { $subsection "syntax-literals" }
@@ -427,18 +428,33 @@ HELP: FORGET:
 HELP: USE:
 { $syntax "USE: vocabulary" }
 { $values { "vocabulary" "a vocabulary name" } }
-{ $description "Adds a new vocabulary at the front of the search path. Subsequent word lookups by the parser will search this vocabulary first." }
+{ $description "Adds a new vocabulary to the search path, loading it first if necessary." }
+{ $notes "If adding the vocabulary introduces ambiguity, referencing the ambiguous names will throw a " { $link ambiguous-use-error } "." }
+{ $errors "Throws an error if the vocabulary does not exist or could not be loaded." } ;
+
+HELP: UNUSE:
+{ $syntax "UNUSE: vocabulary" }
+{ $values { "vocabulary" "a vocabulary name" } }
+{ $description "Removes a vocabulary from the search path." }
 { $errors "Throws an error if the vocabulary does not exist." } ;
 
 HELP: USING:
 { $syntax "USING: vocabularies... ;" }
 { $values { "vocabularies" "a list of vocabulary names" } }
-{ $description "Adds a list of vocabularies to the front of the search path, with later vocabularies taking precedence." }
+{ $description "Adds a list of vocabularies to the search path." }
+{ $notes "If adding the vocabularies introduces ambiguity, referencing the ambiguous names will throw a " { $link ambiguous-use-error } "." }
 { $errors "Throws an error if one of the vocabularies does not exist." } ;
 
 HELP: QUALIFIED:
 { $syntax "QUALIFIED: vocab" }
-{ $description "Similar to " { $link POSTPONE: USE: } " but loads vocabulary with prefix." }
+{ $description "Adds the vocabulary's words, prefixed with the vocabulary name, to the search path." }
+{ $notes "If adding the vocabulary introduces ambiguity, the vocabulary will take precedence when resolving any ambiguous names. This is a rare case; for example, suppose a vocabulary " { $snippet "fish" } " defines a word named " { $snippet "go:fishing" } ", and a vocabulary named " { $snippet "go" } " defines a word named " { $snippet "finishing" } ". Then, the following will call the latter word:"
+  { $code
+  "USE: fish"
+  "QUALIFIED: go"
+  "go:fishing"
+  }
+}
 { $examples { $example
     "USING: prettyprint ;"
     "QUALIFIED: math"
@@ -447,7 +463,7 @@ HELP: QUALIFIED:
 
 HELP: QUALIFIED-WITH:
 { $syntax "QUALIFIED-WITH: vocab word-prefix" }
-{ $description "Works like " { $link POSTPONE: QUALIFIED: } " but uses " { $snippet "word-prefix" } " as prefix." }
+{ $description "Like " { $link POSTPONE: QUALIFIED: } " but uses " { $snippet "word-prefix" } " as prefix." }
 { $examples { $code
     "USING: prettyprint ;"
     "QUALIFIED-WITH: math m"
@@ -457,19 +473,25 @@ HELP: QUALIFIED-WITH:
 
 HELP: FROM:
 { $syntax "FROM: vocab => words ... ;" }
-{ $description "Imports " { $snippet "words" } " from " { $snippet "vocab" } "." }
-{ $examples { $code
-    "FROM: math.parser => bin> hex> ; ! imports only bin> and hex>" } } ;
+{ $description "Adds " { $snippet "words" } " from " { $snippet "vocab" } " to the search path." }
+{ $notes "If adding the words introduces ambiguity, the words will take precedence when resolving any ambiguous names." }
+{ $examples
+  "Both the " { $vocab-link "vocabs.parser" } " and " { $vocab-link "binary-search" } " vocabularies define a word named " { $snippet "search" } ". The following will throw an " { $link ambiguous-use-error } ":"
+  { $code "USING: vocabs.parser binary-search ;" "... search ..." }
+  "Because " { $link POSTPONE: FROM: } " takes precedence over a " { $link POSTPONE: USING: } ", the ambiguity can be resolved explicitly. Suppose you wanted the " { $vocab-link "binary-search" } " vocabulary's " { $snippet "search" } " word:"
+  { $code "USING: vocabs.parser binary-search ;" "FROM: binary-search => search ;" "... search ..." }
+ } ;
 
 HELP: EXCLUDE:
 { $syntax "EXCLUDE: vocab => words ... ;" }
-{ $description "Imports everything from " { $snippet "vocab" } " excluding " { $snippet "words" } "." }
+{ $description "Adds all words except for " { $snippet "words" } " from " { $snippet "vocab" } "  to the search path." }
 { $examples { $code
-    "EXCLUDE: math.parser => bin> hex> ; ! imports everything but bin> and hex>" } } ;
+    "EXCLUDE: math.parser => bin> hex> ;" "! imports everything but bin> and hex>" } } ;
 
 HELP: RENAME:
-{ $syntax "RENAME: word vocab => newname" }
-{ $description "Imports " { $snippet "word" } " from " { $snippet "vocab" } ", but renamed to " { $snippet "newname" } "." }
+{ $syntax "RENAME: word vocab => new-name" }
+{ $description "Imports " { $snippet "word" } " from " { $snippet "vocab" } ", but renamed to " { $snippet "new-name" } "." }
+{ $notes "If adding the words introduces ambiguity, the words will take precedence when resolving any ambiguous names." }
 { $examples { $example
     "USING: prettyprint ;"
     "RENAME: + math => -"
@@ -740,7 +762,7 @@ HELP: MAIN:
 
 HELP: <PRIVATE
 { $syntax "<PRIVATE ... PRIVATE>" }
-{ $description "Marks the start of a block of private word definitions. Private word definitions are placed in a vocabulary named by suffixing the current vocabulary with " { $snippet ".private" } "." }
+{ $description "Begins a block of private word definitions. Private word definitions are placed in the current vocabulary name, suffixed with " { $snippet ".private" } "." }
 { $notes
     "The following is an example of usage:"
     { $code
@@ -770,7 +792,7 @@ HELP: <PRIVATE
 
 HELP: PRIVATE>
 { $syntax "<PRIVATE ... PRIVATE>" }
-{ $description "Marks the end of a block of private word definitions." } ;
+{ $description "Ends a block of private word definitions." } ;
 
 { POSTPONE: <PRIVATE POSTPONE: PRIVATE> } related-words
 
diff --git a/core/syntax/syntax.factor b/core/syntax/syntax.factor
index b29c20850b..56ac9fa36e 100644
--- a/core/syntax/syntax.factor
+++ b/core/syntax/syntax.factor
@@ -49,6 +49,8 @@ IN: bootstrap.syntax
 
     "USE:" [ scan use-vocab ] define-core-syntax
 
+    "UNUSE:" [ scan unuse-vocab ] define-core-syntax
+
     "USING:" [ ";" parse-tokens [ use-vocab ] each ] define-core-syntax
 
     "QUALIFIED:" [ scan dup add-qualified ] define-core-syntax
diff --git a/core/vocabs/parser/parser-docs.factor b/core/vocabs/parser/parser-docs.factor
index d61c998725..e54993b6eb 100644
--- a/core/vocabs/parser/parser-docs.factor
+++ b/core/vocabs/parser/parser-docs.factor
@@ -1,43 +1,7 @@
-USING: help.markup help.syntax parser strings words ;
+USING: help.markup help.syntax parser strings words assocs vocabs ;
 IN: vocabs.parser
 
-ARTICLE: "vocabulary-search-shadow" "Shadowing word names"
-"If adding a vocabulary to the search path results in a word in another vocabulary becoming inaccessible due to the new vocabulary defining a word with the same name, we say that the old word has been " { $emphasis "shadowed" } "."
-$nl
-"Here is an example where shadowing occurs:"
-{ $code
-    "IN: foe"
-    "USING: sequences io ;"
-    ""
-    ": append"
-    "    \"foe::append calls sequences:append\" print  append ;"
-    ""
-    "IN: fee"
-    ""
-    ": append"
-    "    \"fee::append calls fee:append\" print  append ;"
-    ""
-    "IN: fox"
-    "USE: foe"
-    ""
-    ": append"
-    "    \"fox::append calls foe:append\" print  append ;"
-    ""
-    "\"1234\" \"5678\" append print"
-    ""
-    "USE: fox"
-    "\"1234\" \"5678\" append print"
-}
-"When placed in a source file and run, the above code produces the following output:"
-{ $code
-    "foe:append calls sequences:append"
-    "12345678"
-    "fee:append calls foe:append"
-    "foe:append calls sequences:append"
-    "12345678"
-} ;
-
-ARTICLE: "vocabulary-search-errors"  "Word lookup errors"
+ARTICLE: "word-search-errors"  "Word lookup errors"
 "If the parser cannot not find a word in the current vocabulary search path, it attempts to look for the word in all loaded vocabularies."
 $nl
 "If " { $link auto-use? } " mode is off, a restartable error is thrown with a restart for each vocabulary in question, together with a restart which defers the word in the current vocabulary, as if " { $link POSTPONE: DEFER: } " was used."
@@ -47,71 +11,154 @@ $nl
 "If any restarts were invoked, or if " { $link auto-use? } " is on, the parser will print the correct " { $link POSTPONE: USING: } " after parsing completes. This form can be copy and pasted back into the source file."
 { $subsection auto-use? } ;
 
-ARTICLE: "vocabulary-search" "Vocabulary search path"
-"When the parser reads a token, it attempts to look up a word named by that token. The lookup is performed by searching each vocabulary in the search path, in order."
-$nl
-"For a source file the vocabulary search path starts off with one vocabulary:"
-{ $code "syntax" }
-"The " { $vocab-link "syntax" } " vocabulary consists of a set of parsing words for reading Factor data and defining new words."
-$nl
-"In the listener, the " { $vocab-link "scratchpad" } " is the default vocabulary for new word definitions. However, when loading source files, there is no default vocabulary. Defining words before declaring a vocabulary with " { $link POSTPONE: IN: } " results in an error."
-$nl
-"At the interactive listener, the default search path contains many more vocabularies. Details on the default search path and parser invocation are found in " { $link "parser" } "."
-$nl
-"Three parsing words deal with the vocabulary search path:"
-{ $subsection POSTPONE: IN: }
+ARTICLE: "word-search-syntax" "Syntax to control word lookup"
+"Parsing words which make all words in a vocabulary available:"
 { $subsection POSTPONE: USE: }
 { $subsection POSTPONE: USING: }
-"There are some additional parsing words give more control over word lookup than is offered by " { $link POSTPONE: USE: } " and " { $link POSTPONE: USING: } ":"
 { $subsection POSTPONE: QUALIFIED: }
 { $subsection POSTPONE: QUALIFIED-WITH: }
+"Parsing words which make a subset of all words in a vocabulary available:"
 { $subsection POSTPONE: FROM: }
 { $subsection POSTPONE: EXCLUDE: }
 { $subsection POSTPONE: RENAME: }
-"These words are useful when there is no way to avoid using two vocabularies with identical word names in the same source file."
+"Removing vocabularies from the search path:"
+{ $subsection POSTPONE: UNUSE: }
+"In the listener, the " { $vocab-link "scratchpad" } " is the default vocabulary for new word definitions. In source files, there is no default vocabulary. Defining words before declaring a vocabulary with " { $link POSTPONE: IN: } " results in an error."
+{ $subsection POSTPONE: IN: } ;
+
+ARTICLE: "word-search-semantics" "Resolution of ambiguous word names"
+"There is a distinction between parsing words which perform “open” imports versus “closed” imports. An open import introduces all words from a vocabulary as identifiers, except possibly a finite set of exclusions. The " { $link POSTPONE: USE: } ", " { $link POSTPONE: USING: } " and " { $link POSTPONE: EXCLUDE: } " words perform open imports. A closed import only adds a fixed set of identifiers. The " { $link POSTPONE: FROM: } ", " { $link POSTPONE: RENAME: } ", " { $link POSTPONE: QUALIFIED: } " and " { $link POSTPONE: QUALIFIED-WITH: } " words perform closed imports. Note that the latter two are considered as closed imports, due to the fact that all identifiers they introduce are unambiguously qualified with a prefix. The " { $link POSTPONE: IN: } " parsing word also performs a closed import of the newly-created vocabulary."
 $nl
-"Private words can be defined; note that this is just a convention and they can be called from other vocabularies anyway:"
+"When the parser encounters a reference to a word, it first searches the closed imports, in order. Closed imports are searched from the most recent to least recent. If the word could not be found this way, it searches open imports. Unlike closed imports, with open imports, the order does not matter -- instead, if more than one vocabulary defines a word with this name, an error is thrown."
+{ $subsection ambiguous-use-error }
+"To resolve the error, add a closed import, using " { $link POSTPONE: FROM: } ", " { $link POSTPONE: QUALIFIED: } " or " { $link POSTPONE: QUALIFIED-WITH: } ". The closed import will then take precedence over the open imports, and the ambiguity will be resolved."
+$nl
+"The rationale for this behavior is as follows. Open imports are named such because they are open to future extension; if a future version of a vocabulary that you use adds new words, those new words will now be in scope in your source file, too. To avoid problems, any references to the new word have to be resolved since the parser cannot safely determine which vocabulary was meant. This problem can be avoided entirely by using only closed imports, but this leads to additional verbosity."
+$nl
+"In practice, a small set of guidelines helps avoid name clashes:"
+{ $list
+  "Keep vocabularies small"
+  { "Hide internal words using " { $link POSTPONE: <PRIVATE } }
+  { "Make good use of " { $link POSTPONE: FROM: } ", " { $link POSTPONE: QUALIFIED: } " or " { $link POSTPONE: QUALIFIED-WITH: } }
+} ;
+
+ARTICLE: "word-search-private" "Private words"
+"Words which only serve as implementation detail should be defined in a private code block. Words in a private code blocks get defined in a vocabulary whose name is the name of the current vocabulary suffixed with " { $snippet ".private" } ". Privacy is not enforced by the system; private words can be called from other vocabularies, and from the listener. However, this should be avoided where possible."
 { $subsection POSTPONE: <PRIVATE }
-{ $subsection POSTPONE: PRIVATE> }
-{ $subsection "vocabulary-search-errors" }
-{ $subsection "vocabulary-search-shadow" }
+{ $subsection POSTPONE: PRIVATE> } ;
+
+ARTICLE: "word-search" "Parse-time word lookup"
+"When the parser reads a word name, it resolves the word at parse-time, looking up the " { $link word } " instance in the right vocabulary and adding it to the parse tree."
+$nl
+"Initially, only words from the " { $vocab-link "syntax" } " vocabulary are available in source files. Since most files will use words in other vocabularies, they will need to make those words available using a set of parsing words."
+{ $subsection "word-search-syntax" }
+{ $subsection "word-search-private" }
+{ $subsection "word-search-semantics" }
+{ $subsection "word-search-errors" }
 { $see-also "words" } ;
 
-ABOUT: "vocabulary-search"
+ARTICLE: "word-search-parsing" "Word lookup in parsing words"
+"The parsing words described in " { $link "word-search-syntax" } " are implemented using the below words, which you can also call from your own parsing words."
+$nl
+"The current state used for word search is stored in a " { $emphasis "manifest" } ":"
+{ $subsection manifest }
+"Words for working with the current manifest:"
+{ $subsection use-vocab }
+{ $subsection unuse-vocab }
+{ $subsection only-use-vocabs }
+{ $subsection add-qualified }
+{ $subsection add-words-from }
+{ $subsection add-words-excluding }
+"Words used to implement " { $link POSTPONE: IN: } ":"
+{ $subsection current-vocab }
+{ $subsection set-current-vocab }
+"Words used to implement " { $link "word-search-private" } ":"
+{ $subsection begin-private }
+{ $subsection end-private } ;
 
-HELP: use
-{ $var-description "A variable holding the current vocabulary search path as a sequence of assocs." } ;
+ABOUT: "word-search"
 
-HELP: in
-{ $var-description "A variable holding the name of the current vocabulary for new definitions." } ;
+HELP: manifest
+{ $var-description "The current manifest. Only set at parse time." }
+{ $class-description "Encapsulates the current vocabulary, as well as the vocabulary search path." } ;
 
-HELP: current-vocab
-{ $values { "str" "a vocabulary" } }
-{ $description "Returns the vocabulary stored in the " { $link in } " symbol. Throws an error if the current vocabulary is " { $link f } "." } ;
+HELP: <manifest>
+{ $values { "manifest" manifest } }
+{ $description "Creates a new manifest." } ;
 
-HELP: (add-use)
-{ $values { "vocab" "an assoc mapping strings to words" } }
-{ $description "Adds an assoc at the front of the search path." }
-$parsing-note ;
-
-HELP: add-use
-{ $values { "vocab" string } }
-{ $description "Adds a new vocabulary at the front of the search path after loading it if necessary. Subsequent word lookups by the parser will search this vocabulary first." }
-$parsing-note
-{ $errors "Throws an error if the vocabulary does not exist." } ;
-
-HELP: set-use
-{ $values { "seq" "a sequence of strings" } }
-{ $description "Sets the vocabulary search path. Later vocabularies take precedence." }
-{ $errors "Throws an error if one of the vocabularies does not exist." }
-$parsing-note ;
-
-HELP: set-in
+HELP: set-current-vocab
 { $values { "name" string } }
 { $description "Sets the current vocabulary where new words will be defined, creating the vocabulary first if it does not exist." }
-$parsing-note ;
+{ $notes "This word is used to implement " { $link POSTPONE: IN: } "." } ;
+
+HELP: no-current-vocab
+{ $error-description "Thrown when a new word is defined in a source file that does not have an " { $link POSTPONE: IN: } " form." } ;
+
+HELP: current-vocab
+{ $values { "vocab" vocab } }
+{ $description "Returns the current vocabulary, where new words will be defined." }
+{ $errors "Throws an error if the current vocabulary has not been set." } ;
+
+HELP: begin-private
+{ $description "Begins a block of private word definitions. Private word definitions are placed in the current vocabulary name, suffixed with " { $snippet ".private" } "." }
+{ $notes "This word is used to implement " { $link POSTPONE: <PRIVATE } "." } ;
+
+HELP: end-private
+{ $description "Ends a block of private word definitions." }
+{ $notes "This word is used to implement " { $link POSTPONE: PRIVATE> } "." } ;
+
+HELP: use-vocab
+{ $values { "vocab" "a vocabulary specifier" } }
+{ $description "Adds a vocabulary to the current manifest." }
+{ $notes "This word is used to implement " { $link POSTPONE: USE: } "." } ;
+
+HELP: unuse-vocab
+{ $values { "vocab" "a vocabulary specifier" } }
+{ $description "Removes a vocabulary from the current manifest." }
+{ $notes "This word is used to implement " { $link POSTPONE: UNUSE: } "." } ;
+
+HELP: only-use-vocabs
+{ $values { "vocabs" "a sequence of vocabulary specifiers" } }
+{ $description "Replaces the current manifest's vocabulary search path with the given set of vocabularies." } ;
+
+HELP: add-qualified
+{ $values { "vocab" "a vocabulary specifier" } { "prefix" string } }
+{ $description "Adds the vocabulary's words, prefixed with the given string, to the current manifest." }
+{ $notes "If adding the vocabulary introduces ambiguity, the vocabulary will take precedence when resolving any ambiguous names. See the example in " { $link POSTPONE: QUALIFIED: } " for further explanation." } ;
+
+HELP: add-words-from
+{ $values { "vocab" "a vocabulary specifier" } { "words" "a sequence of word names" } }
+{ $description "Adds " { $snippet "words" } " from " { $snippet "vocab" } " to the current manifest." }
+{ $notes "This word is used to implement " { $link POSTPONE: FROM: } "." } ;
+
+HELP: add-words-excluding
+{ $values { "vocab" "a vocabulary specifier" } { "words" "a sequence of word names" } }
+{ $description "Adds all words except for " { $snippet "words" } " from " { $snippet "vocab" } "  to the manifest." }
+{ $notes "This word is used to implement " { $link POSTPONE: EXCLUDE: } "." } ;
+
+HELP: add-renamed-word
+{ $values { "word" string } { "vocab" "a vocabulary specifier" } { "new-name" string } }
+{ $description "Imports " { $snippet "word" } " from " { $snippet "vocab" } ", but renamed to " { $snippet "new-name" } "." }
+{ $notes "This word is used to implement " { $link POSTPONE: RENAME: } "." } ;
+
+HELP: use-words
+{ $values { "assoc" assoc } }
+{ $description "Adds an assoc mapping word names to words to the current manifest." }
+{ $notes "This word is used by " { $link "locals" } " to implement lexically-scoped names." } ;
+
+HELP: unuse-words
+{ $values { "assoc" assoc } }
+{ $description "Removes an assoc mapping word names to words from the current manifest." }
+{ $notes "This word is used by " { $link "locals" } " to implement lexically-scoped names." } ;
+
+HELP: ambiguous-use-error
+{ $error-description "Thrown when a word name referenced in source file is available in more than one vocabulary in the manifest. Such cases must be explicitly disambiguated using " { $link POSTPONE: FROM: } ", " { $link POSTPONE: EXCLUDE: } ", " { $link POSTPONE: QUALIFIED: } ", or " { $link POSTPONE: QUALIFIED-WITH: } "." } ;
+
+HELP: search-manifest
+{ $values { "name" string } { "manifest" manifest } { "word/f" { $maybe word } } }
+{ $description "Searches for a word by name in the given manifest. If no such word could be found, outputs " { $link f } "." } ;
 
 HELP: search
-{ $values { "str" string } { "word/f" { $maybe word } } }
-{ $description "Searches for a word by name in the current vocabulary search path. If no such word could be found, outputs " { $link f } "." }
+{ $values { "name" string } { "word/f" { $maybe word } } }
+{ $description "Searches for a word by name in the current manifest. If no such word could be found, outputs " { $link f } "." }
 $parsing-note ;
diff --git a/core/vocabs/parser/parser.factor b/core/vocabs/parser/parser.factor
index 426894794e..f6c14cead9 100644
--- a/core/vocabs/parser/parser.factor
+++ b/core/vocabs/parser/parser.factor
@@ -32,8 +32,7 @@ M: manifest clone
     manifest get
     [ search-vocabs>> delete-all ]
     [ qualified-vocabs>> delete-all ]
-    [ extra-words>> delete-all ]
-    tri ;
+    bi ;
 
 : (use-vocab) ( vocab -- vocab seq )
     load-vocab manifest get search-vocabs>> ;
@@ -44,22 +43,25 @@ M: manifest clone
 : (from) ( vocab words -- vocab words words' assoc )
     2dup swap load-vocab words>> ;
 
-: (use-words) ( assoc -- assoc seq )
-    manifest get extra-words>> ;
-
 : extract-words ( seq assoc -- assoc' )
     extract-keys dup [ [ drop ] [ no-word-error ] if ] assoc-each ;
 
 : (lookup) ( name assoc -- word/f )
     at dup forward-reference? [ drop f ] when ;
 
+TUPLE: extra-words words ;
+
+C: <extra-words> extra-words
+
+: (use-words) ( assoc -- extra-words seq )
+    <extra-words> manifest get qualified-vocabs>> ;
+
 PRIVATE>
 
 : set-current-vocab ( name -- )
-    create-vocab manifest get
-    [ (>>current-vocab) ]
-    [ [ words>> ] dip extra-words>> push ]
-    2bi ; 
+    create-vocab
+    [ manifest get (>>current-vocab) ]
+    [ words>> <extra-words> (add-qualified) ] bi ;
 
 TUPLE: no-current-vocab ;
 
@@ -124,9 +126,9 @@ TUPLE: rename word vocab words ;
 : add-renamed-word ( word vocab new-name -- )
     <rename> (add-qualified) ;
 
-: use-words ( words -- ) (use-words) push ;
+: use-words ( assoc -- ) (use-words) push ;
 
-: unuse-words ( words -- ) (use-words) delq ;
+: unuse-words ( assoc -- ) (use-words) delq ;
 
 ERROR: ambiguous-use-error words ;
 
@@ -148,17 +150,10 @@ ERROR: ambiguous-use-error words ;
     qualified-vocabs>>
     (vocab-search) 0 = [ drop f ] [ peek ] if ;
 
-: word-search ( name manifest -- word/f )
-    extra-words>> [ (lookup) ] with map-find-last drop ;
-
 PRIVATE>
 
 : search-manifest ( name manifest -- word/f )
-    2dup word-search dup [ 2nip ] [
-        drop 2dup qualified-search dup [ 2nip ] [
-            drop vocab-search
-        ] if
-    ] if ;
+    2dup qualified-search dup [ 2nip ] [ drop vocab-search ] if ;
 
 : search ( name -- word/f )
     manifest get search-manifest ;
diff --git a/core/words/words-docs.factor b/core/words/words-docs.factor
index a04b95bcfd..574f8afe81 100644
--- a/core/words/words-docs.factor
+++ b/core/words/words-docs.factor
@@ -8,7 +8,7 @@ ARTICLE: "interned-words" "Looking up and creating words"
 $nl
 "Words whose names are known at parse time -- that is, most words making up your program -- can be referenced in source code by stating their name. However, the parser itself, and sometimes code you write, will need to create look up words dynamically."
 $nl
-"Parsing words add definitions to the current vocabulary. When a source file is being parsed, the current vocabulary is initially set to " { $vocab-link "scratchpad" } ". The current vocabulary may be changed with the " { $link POSTPONE: IN: } " parsing word (see " { $link "vocabulary-search" } ")."
+"Parsing words add definitions to the current vocabulary. When a source file is being parsed, the current vocabulary is initially set to " { $vocab-link "scratchpad" } ". The current vocabulary may be changed with the " { $link POSTPONE: IN: } " parsing word (see " { $link "word-search" } ")."
 { $subsection create }
 { $subsection create-in }
 { $subsection lookup } ;
diff --git a/extra/bank/bank-tests.factor b/extra/bank/bank-tests.factor
index 5014d53019..0d11b11acf 100644
--- a/extra/bank/bank-tests.factor
+++ b/extra/bank/bank-tests.factor
@@ -1,5 +1,6 @@
 USING: accessors arrays bank calendar kernel math math.functions
 namespaces make tools.test tools.walker ;
+FROM: bank => balance>> ;
 IN: bank.tests
 
 SYMBOL: my-account
diff --git a/extra/fuel/xref/xref.factor b/extra/fuel/xref/xref.factor
index 3dfa129a7f..3e3279ece7 100644
--- a/extra/fuel/xref/xref.factor
+++ b/extra/fuel/xref/xref.factor
@@ -36,10 +36,8 @@ MEMO: (vocab-words) ( name -- seq )
 
 : current-words ( -- seq )
     manifest get
-    [ search-vocabs>> [ words>> ] map ]
-    [ qualified-vocabs>> [ words>> ] map ]
-    [ extra-words>> ]
-    tri 3append assoc-combine keys ; inline
+    [ search-vocabs>> ] [ qualified-vocabs>> ] bi [ words>> ] bi@
+    assoc-union keys ; inline
 
 : vocabs-words ( names -- seq )
     prune [ (vocab-words) ] map concat ; inline
diff --git a/extra/infix/infix-docs.factor b/extra/infix/infix-docs.factor
index 4a2ec963ee..74831af7fb 100644
--- a/extra/infix/infix-docs.factor
+++ b/extra/infix/infix-docs.factor
@@ -54,7 +54,7 @@ $nl
 }
 "The standard precedence rules apply: Grouping with parentheses before " { $snippet "*" } ", " { $snippet "/" } "and " { $snippet "%" } " before " { $snippet "+" } " and " { $snippet "-" } "."
 { $example
-    "USING: infix prettyprint ;"
+    "USE: infix"
     "[infix 5-40/10*2 infix] ."
     "-3"
 }
@@ -65,7 +65,7 @@ $nl
     "The word name must consist of the letters a-z, A-Z, _ or 0-9, and the first character can't be a number."
 }
 { $example
-    "USING: infix locals math math.functions prettyprint ;"
+    "USING: infix locals math.functions ;"
     ":: binary_entropy ( p -- h )"
     "    [infix -(p*log(p) + (1-p)*log(1-p)) / log(2) infix] ;"
     "[infix binary_entropy( sqrt(0.25) ) infix] ."
@@ -74,13 +74,13 @@ $nl
 $nl
 "You can access " { $vocab-link "sequences" } " inside infix expressions with the familiar " { $snippet "arr[index]" } " notation."
 { $example
-    "USING: arrays infix prettyprint ;"
+    "USING: arrays infix ;"
     "[infix| myarr [ { 1 2 3 4 } ] | myarr[4/2]*3 infix] ."
     "9"
 }
 "Please note: in Factor " { $emphasis "fixnums are sequences too." } " If you are not careful with sequence accesses you may introduce subtle bugs:"
 { $example
-    "USING: arrays infix locals prettyprint ;"
+    "USING: arrays infix locals ;"
     ":: add-2nd-element ( x y -- res )"
     "    [infix x[1] + y[1] infix] ;"
     "{ 1 2 3 } 5 add-2nd-element ."
diff --git a/extra/math/floating-point/floating-point-tests.factor b/extra/math/floating-point/floating-point-tests.factor
index 9e5b5c67aa..2f13237c9d 100644
--- a/extra/math/floating-point/floating-point-tests.factor
+++ b/extra/math/floating-point/floating-point-tests.factor
@@ -1,7 +1,7 @@
 ! Copyright (C) 2008 Doug Coleman.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: tools.test math.floating-point math.constants kernel
-math.constants fry sequences kernel math ;
+USING: tools.test math.floating-point kernel
+math.constants fry sequences math ;
 IN: math.floating-point.tests
 
 [ t ] [ pi >double< >double pi = ] unit-test
diff --git a/extra/monads/monads-tests.factor b/extra/monads/monads-tests.factor
index ee63b14f3c..0f1eb8edda 100644
--- a/extra/monads/monads-tests.factor
+++ b/extra/monads/monads-tests.factor
@@ -1,4 +1,5 @@
 USING: tools.test math kernel sequences lists promises monads ;
+FROM: monads => do ;
 IN: monads.tests
 
 [ 5 ] [ 1 identity-monad return [ 4 + ] fmap run-identity ] unit-test
diff --git a/extra/roles/roles-tests.factor b/extra/roles/roles-tests.factor
index fcbc20db16..95c2fe1138 100644
--- a/extra/roles/roles-tests.factor
+++ b/extra/roles/roles-tests.factor
@@ -1,6 +1,7 @@
 ! (c)2009 Joe Groff bsd license
 USING: accessors classes.tuple compiler.units kernel qw roles sequences
 tools.test ;
+FROM: roles => TUPLE: ;
 IN: roles.tests
 
 ROLE: fork tines ;
diff --git a/extra/tetris/game/game-tests.factor b/extra/tetris/game/game-tests.factor
index 047c20d053..e505691c3a 100644
--- a/extra/tetris/game/game-tests.factor
+++ b/extra/tetris/game/game-tests.factor
@@ -1,5 +1,6 @@
 USING: accessors kernel tetris.game tetris.board tetris.piece tools.test
 sequences ;
+FROM: tetris.game => level>> ;
 
 [ t ] [ <default-tetris> [ current-piece ] [ next-piece ] bi and t f ? ] unit-test
 [ t ] [ <default-tetris> { 1 1 } can-move? ] unit-test

From 5494f61df9f8c3e56d3db800193602b3722efe1d Mon Sep 17 00:00:00 2001
From: Slava Pestov <slava@slava-pestovs-macbook-pro.local>
Date: Sat, 16 May 2009 02:32:55 -0500
Subject: [PATCH 10/23] Auto-use now prints out USING: forms again

---
 .../prettyprint/sections/sections-docs.factor |  7 +-
 basis/prettyprint/sections/sections.factor    | 16 ++++
 basis/vocabs/prettyprint/authors.txt          |  1 +
 .../prettyprint/prettyprint-tests.factor      | 47 ++++++++++
 basis/vocabs/prettyprint/prettyprint.factor   | 86 +++++++++++++++++++
 core/vocabs/parser/parser.factor              |  8 +-
 6 files changed, 159 insertions(+), 6 deletions(-)
 create mode 100644 basis/vocabs/prettyprint/authors.txt
 create mode 100644 basis/vocabs/prettyprint/prettyprint-tests.factor
 create mode 100644 basis/vocabs/prettyprint/prettyprint.factor

diff --git a/basis/prettyprint/sections/sections-docs.factor b/basis/prettyprint/sections/sections-docs.factor
index ce7430d040..f0d369297c 100644
--- a/basis/prettyprint/sections/sections-docs.factor
+++ b/basis/prettyprint/sections/sections-docs.factor
@@ -1,6 +1,6 @@
 USING: prettyprint io kernel help.markup help.syntax
 prettyprint.config words hashtables math
-strings definitions ;
+strings definitions quotations ;
 IN: prettyprint.sections
 
 HELP: position
@@ -13,7 +13,6 @@ HELP: line-limit?
 { $values { "?" "a boolean" } }
 { $description "Tests if the line number limit has been reached, and thus if prettyprinting should stop." } ;
 
-
 HELP: do-indent
 { $description "Outputs the current indent nesting to " { $link output-stream } "." } ;
 
@@ -211,3 +210,7 @@ $prettyprinting-note ;
 HELP: do-pprint
 { $values { "block" block } }
 { $description "Recursively output all children of the given block. The continuation is restored and output terminates if the line length is exceeded; this test is performed in " { $link fresh-line } "." } ;
+
+HELP: with-pprint
+{ $values { "obj" object } { "quot" quotation } }
+{ $description "Sets up the prettyprinter and calls the quotation in a new scope. The quotation should add sections to the top-level block. When the quotation returns, the top-level block is printed to " { $link output-stream } "." } ;
diff --git a/basis/prettyprint/sections/sections.factor b/basis/prettyprint/sections/sections.factor
index faa254be69..f72c426533 100644
--- a/basis/prettyprint/sections/sections.factor
+++ b/basis/prettyprint/sections/sections.factor
@@ -326,3 +326,19 @@ M: block long-section ( block -- )
             ] each
         ] each
     ] if-nonempty ;
+
+: make-pprint ( obj quot -- block in use )
+    [
+        0 position set
+        H{ } clone pprinter-use set
+        V{ } clone recursion-check set
+        V{ } clone pprinter-stack set
+        over <object
+        call
+        pprinter-block
+        pprinter-in get
+        pprinter-use get keys
+    ] with-scope ; inline
+
+: with-pprint ( obj quot -- )
+    make-pprint 2drop do-pprint ; inline
\ No newline at end of file
diff --git a/basis/vocabs/prettyprint/authors.txt b/basis/vocabs/prettyprint/authors.txt
new file mode 100644
index 0000000000..d4f5d6b3ae
--- /dev/null
+++ b/basis/vocabs/prettyprint/authors.txt
@@ -0,0 +1 @@
+Slava Pestov
\ No newline at end of file
diff --git a/basis/vocabs/prettyprint/prettyprint-tests.factor b/basis/vocabs/prettyprint/prettyprint-tests.factor
new file mode 100644
index 0000000000..151e5d1782
--- /dev/null
+++ b/basis/vocabs/prettyprint/prettyprint-tests.factor
@@ -0,0 +1,47 @@
+IN: vocabs.prettyprint.tests
+USING: vocabs.prettyprint tools.test io.streams.string multiline eval ;
+
+: manifest-test-1 ( -- string )
+    <" USING: kernel namespaces vocabs.parser vocabs.prettyprint ;
+
+    << manifest get pprint-manifest >> "> ;
+
+[
+<" USING: kernel namespaces syntax vocabs.parser
+vocabs.prettyprint ;">
+]
+[ [ manifest-test-1 eval( -- ) ] with-string-writer ] unit-test
+
+: manifest-test-2 ( -- string )
+    <" USING: kernel namespaces vocabs.parser vocabs.prettyprint ;
+    IN: vocabs.prettyprint.tests
+
+    << manifest get pprint-manifest >> "> ;
+
+[
+<" USING: kernel namespaces syntax vocabs.parser
+vocabs.prettyprint ;
+IN: vocabs.prettyprint.tests">
+]
+[ [ manifest-test-2 eval( -- ) ] with-string-writer ] unit-test
+
+: manifest-test-3 ( -- string )
+    <" USING: kernel namespaces vocabs.parser vocabs.prettyprint ;
+    FROM: math => + - ;
+    QUALIFIED: system
+    QUALIFIED-WITH: assocs a
+    EXCLUDE: parser => run-file ;
+    IN: vocabs.prettyprint.tests
+
+    << manifest get pprint-manifest >> "> ;
+
+[
+<" USING: kernel namespaces syntax vocabs.parser
+vocabs.prettyprint ;
+FROM: math => + - ;
+QUALIFIED: system
+QUALIFIED-WITH: assocs a
+EXCLUDE: parser => run-file ;
+IN: vocabs.prettyprint.tests">
+]
+[ [ manifest-test-3 eval( -- ) ] with-string-writer ] unit-test
\ No newline at end of file
diff --git a/basis/vocabs/prettyprint/prettyprint.factor b/basis/vocabs/prettyprint/prettyprint.factor
new file mode 100644
index 0000000000..d491acd33b
--- /dev/null
+++ b/basis/vocabs/prettyprint/prettyprint.factor
@@ -0,0 +1,86 @@
+! Copyright (C) 2009 Slava Pestov.
+! See http://factorcode.org/license.txt for BSD license.
+USING: accessors kernel sorting sequences vocabs io io.styles arrays assocs
+namespaces sets parser colors prettyprint.backend prettyprint.sections
+vocabs.parser make fry math.order ;
+IN: vocabs.prettyprint
+
+: pprint-vocab ( vocab -- )
+    [ vocab-name ] [ vocab ] bi present-text ;
+
+: pprint-in ( vocab -- )
+    [ \ IN: pprint-word pprint-vocab ] with-pprint ;
+
+<PRIVATE
+
+: sort-vocabs ( seq -- seq' )
+    [ [ vocab-name ] compare ] sort ;
+
+: pprint-using ( seq -- )
+    [ "syntax" vocab = not ] filter
+    sort-vocabs [
+        \ USING: pprint-word
+        [ pprint-vocab ] each
+        \ ; pprint-word
+    ] with-pprint ;
+
+GENERIC: pprint-qualified ( qualified -- )
+
+M: qualified pprint-qualified ( qualified -- )
+    [
+        dup [ vocab>> vocab-name ] [ prefix>> ] bi = [
+            \ QUALIFIED: pprint-word
+            vocab>> pprint-vocab
+        ] [
+            \ QUALIFIED-WITH: pprint-word
+            [ vocab>> pprint-vocab ] [ prefix>> text ] bi
+        ] if
+    ] with-pprint ;
+
+M: from pprint-qualified ( from -- )
+    [
+        \ FROM: pprint-word
+        [ vocab>> pprint-vocab "=>" text ]
+        [ names>> [ text ] each ] bi
+        \ ; pprint-word
+    ] with-pprint ;
+
+M: exclude pprint-qualified ( exclude -- )
+    [
+        \ EXCLUDE: pprint-word
+        [ vocab>> pprint-vocab "=>" text ]
+        [ names>> [ text ] each ] bi
+        \ ; pprint-word
+    ] with-pprint ;
+
+M: rename pprint-qualified ( rename -- )
+    [
+        \ RENAME: pprint-word
+        [ word>> text ]
+        [ vocab>> text "=>" text ]
+        [ words>> >alist first first text ]
+        tri
+    ] with-pprint ;
+
+PRIVATE>
+
+: pprint-manifest ( manifest -- )
+    [
+        [ search-vocabs>> [ '[ _ pprint-using ] , ] unless-empty ]
+        [ qualified-vocabs>> [ extra-words? not ] filter [ '[ _ pprint-qualified ] , ] each ]
+        [ current-vocab>> [ '[ _ pprint-in ] , ] when* ]
+        tri
+    ] { } make
+    [ nl ] [ call( -- ) ] interleave ;
+
+[
+    nl
+    { { font-style bold } { font-name "sans-serif" } } [
+        "Restarts were invoked adding vocabularies to the search path." print
+        "To avoid doing this in the future, add the following USING:" print
+        "and IN: forms at the top of the source file:" print nl
+    ] with-style
+    { { page-color T{ rgba f 0.8 0.8 0.8 1.0 } } }
+    [ manifest get pprint-manifest ] with-nesting
+    nl nl
+] print-use-hook set-global
\ No newline at end of file
diff --git a/core/vocabs/parser/parser.factor b/core/vocabs/parser/parser.factor
index f6c14cead9..c76890e845 100644
--- a/core/vocabs/parser/parser.factor
+++ b/core/vocabs/parser/parser.factor
@@ -26,6 +26,10 @@ M: manifest clone
         [ clone ] change-qualified-vocabs
         [ clone ] change-extra-words ;
 
+TUPLE: extra-words words ;
+
+C: <extra-words> extra-words
+
 <PRIVATE
 
 : clear-manifest ( -- )
@@ -49,10 +53,6 @@ M: manifest clone
 : (lookup) ( name assoc -- word/f )
     at dup forward-reference? [ drop f ] when ;
 
-TUPLE: extra-words words ;
-
-C: <extra-words> extra-words
-
 : (use-words) ( assoc -- extra-words seq )
     <extra-words> manifest get qualified-vocabs>> ;
 

From 274655e77c85304975ed270f82023009fc57651c Mon Sep 17 00:00:00 2001
From: Slava Pestov <slava@slava-pestovs-macbook-pro.local>
Date: Sat, 16 May 2009 04:26:45 -0500
Subject: [PATCH 11/23] More work on auto-use

---
 basis/help/markup/markup.factor               |  3 +--
 .../prettyprint/prettyprint-tests.factor      |  9 +++-----
 basis/vocabs/prettyprint/prettyprint.factor   |  4 ++--
 core/parser/parser.factor                     | 11 +++-------
 core/vocabs/parser/parser.factor              | 21 ++++++++++++++-----
 extra/fuel/fuel.factor                        |  4 ++--
 6 files changed, 27 insertions(+), 25 deletions(-)

diff --git a/basis/help/markup/markup.factor b/basis/help/markup/markup.factor
index 04b6d90883..6f82a6f50b 100644
--- a/basis/help/markup/markup.factor
+++ b/basis/help/markup/markup.factor
@@ -5,6 +5,7 @@ hashtables namespaces make parser prettyprint sequences strings
 io.styles vectors words math sorting splitting classes slots fry
 sets vocabs help.stylesheet help.topics vocabs.loader quotations
 combinators see present ;
+FROM: prettyprint.sections => with-pprint ;
 IN: help.markup
 
 PREDICATE: simple-element < array
@@ -348,8 +349,6 @@ M: f ($instance)
     drop
     "Throws an error if the I/O operation fails." $errors ;
 
-FROM: prettyprint.private => with-pprint ;
-
 : $prettyprinting-note ( children -- )
     drop {
         "This word should only be called from inside the "
diff --git a/basis/vocabs/prettyprint/prettyprint-tests.factor b/basis/vocabs/prettyprint/prettyprint-tests.factor
index 151e5d1782..9ad0aae59d 100644
--- a/basis/vocabs/prettyprint/prettyprint-tests.factor
+++ b/basis/vocabs/prettyprint/prettyprint-tests.factor
@@ -7,8 +7,7 @@ USING: vocabs.prettyprint tools.test io.streams.string multiline eval ;
     << manifest get pprint-manifest >> "> ;
 
 [
-<" USING: kernel namespaces syntax vocabs.parser
-vocabs.prettyprint ;">
+<" USING: kernel namespaces vocabs.parser vocabs.prettyprint ;">
 ]
 [ [ manifest-test-1 eval( -- ) ] with-string-writer ] unit-test
 
@@ -19,8 +18,7 @@ vocabs.prettyprint ;">
     << manifest get pprint-manifest >> "> ;
 
 [
-<" USING: kernel namespaces syntax vocabs.parser
-vocabs.prettyprint ;
+<" USING: kernel namespaces vocabs.parser vocabs.prettyprint ;
 IN: vocabs.prettyprint.tests">
 ]
 [ [ manifest-test-2 eval( -- ) ] with-string-writer ] unit-test
@@ -36,8 +34,7 @@ IN: vocabs.prettyprint.tests">
     << manifest get pprint-manifest >> "> ;
 
 [
-<" USING: kernel namespaces syntax vocabs.parser
-vocabs.prettyprint ;
+<" USING: kernel namespaces vocabs.parser vocabs.prettyprint ;
 FROM: math => + - ;
 QUALIFIED: system
 QUALIFIED-WITH: assocs a
diff --git a/basis/vocabs/prettyprint/prettyprint.factor b/basis/vocabs/prettyprint/prettyprint.factor
index d491acd33b..2ada653af1 100644
--- a/basis/vocabs/prettyprint/prettyprint.factor
+++ b/basis/vocabs/prettyprint/prettyprint.factor
@@ -77,8 +77,8 @@ PRIVATE>
     nl
     { { font-style bold } { font-name "sans-serif" } } [
         "Restarts were invoked adding vocabularies to the search path." print
-        "To avoid doing this in the future, add the following USING:" print
-        "and IN: forms at the top of the source file:" print nl
+        "To avoid doing this in the future, add the following forms" print
+        "at the top of the source file:" print nl
     ] with-style
     { { page-color T{ rgba f 0.8 0.8 0.8 1.0 } } }
     [ manifest get pprint-manifest ] with-nesting
diff --git a/core/parser/parser.factor b/core/parser/parser.factor
index 31b5286c18..eb8d77959e 100644
--- a/core/parser/parser.factor
+++ b/core/parser/parser.factor
@@ -38,17 +38,13 @@ M: parsing-word stack-effect drop (( parsed -- parsed )) ;
 
 : CREATE-WORD ( -- word ) CREATE dup reset-generic ;
 
-SYMBOL: amended-use
-
 SYMBOL: auto-use?
 
 : no-word-restarted ( restart-value -- word )
     dup word? [
         dup vocabulary>>
-        [ use-vocab ]
-        [ amended-use get dup [ push ] [ 2drop ] if ]
-        [ "Added \"" "\" vocabulary to search path" surround note. ]
-        tri
+        [ auto-use-vocab ]
+        [ "Added \"" "\" vocabulary to search path" surround note. ] bi
     ] [ create-in ] if ;
 
 : no-word ( name -- newword )
@@ -198,9 +194,8 @@ print-use-hook [ [ ] ] initialize
 
 : parse-fresh ( lines -- quot )
     [
-        V{ } clone amended-use set
         parse-lines
-        amended-use get empty? [ print-use-hook get call( -- ) ] unless
+        auto-used? [ print-use-hook get call( -- ) ] when
     ] with-file-vocabs ;
 
 : parsing-file ( file -- )
diff --git a/core/vocabs/parser/parser.factor b/core/vocabs/parser/parser.factor
index c76890e845..43451b4c86 100644
--- a/core/vocabs/parser/parser.factor
+++ b/core/vocabs/parser/parser.factor
@@ -3,7 +3,7 @@
 ! See http://factorcode.org/license.txt for BSD license.
 USING: assocs hashtables kernel namespaces sequences
 sets strings vocabs sorting accessors arrays compiler.units
-combinators vectors splitting continuations ;
+combinators vectors splitting continuations math ;
 IN: vocabs.parser
 
 ERROR: no-word-error name ;
@@ -12,22 +12,28 @@ TUPLE: manifest
 current-vocab
 { search-vocabs vector }
 { qualified-vocabs vector }
-{ extra-words vector } ;
+{ extra-words vector }
+{ auto-used vector } ;
 
 : <manifest> ( -- manifest )
     manifest new
         V{ } clone >>search-vocabs
         V{ } clone >>qualified-vocabs
-        V{ } clone >>extra-words ;
+        V{ } clone >>extra-words
+        V{ } clone >>auto-used ;
 
 M: manifest clone
     call-next-method
         [ clone ] change-search-vocabs
         [ clone ] change-qualified-vocabs
-        [ clone ] change-extra-words ;
+        [ clone ] change-extra-words
+        [ clone ] change-auto-used ;
 
 TUPLE: extra-words words ;
 
+M: extra-words equal?
+    over extra-words? [ [ words>> ] bi@ eq? ] [ 2drop f ] if ;
+
 C: <extra-words> extra-words
 
 <PRIVATE
@@ -83,6 +89,11 @@ TUPLE: no-current-vocab ;
 
 : use-vocab ( vocab -- ) (use-vocab) push ;
 
+: auto-use-vocab ( vocab -- )
+    [ use-vocab ] [ manifest get auto-used>> push ] bi ;
+
+: auto-used? ( -- ? ) manifest get auto-used>> length 0 > ;
+
 : unuse-vocab ( vocab -- ) (use-vocab) delq ;
 
 : only-use-vocabs ( vocabs -- )
@@ -128,7 +139,7 @@ TUPLE: rename word vocab words ;
 
 : use-words ( assoc -- ) (use-words) push ;
 
-: unuse-words ( assoc -- ) (use-words) delq ;
+: unuse-words ( assoc -- ) (use-words) delete ;
 
 ERROR: ambiguous-use-error words ;
 
diff --git a/extra/fuel/fuel.factor b/extra/fuel/fuel.factor
index a9ed17877e..5d4149867b 100644
--- a/extra/fuel/fuel.factor
+++ b/extra/fuel/fuel.factor
@@ -3,7 +3,7 @@
 
 USING: accessors assocs compiler.units continuations fuel.eval fuel.help
 fuel.remote fuel.xref help.topics io.pathnames kernel namespaces parser
-sequences tools.scaffold vocabs.loader words ;
+sequences tools.scaffold vocabs.loader vocabs.parser words ;
 
 IN: fuel
 
@@ -46,7 +46,7 @@ SYMBOL: :uses-suggestions
     dup length 1 = [ first restart ] [ drop ] if ;
 
 : fuel-set-use-hook ( -- )
-    [ amended-use get clone :uses prefix fuel-eval-set-result ]
+    [ manifest get auto-used>> clone :uses prefix fuel-eval-set-result ]
     print-use-hook set ;
 
 : (fuel-get-uses) ( lines -- )

From 7c388d702a78b5bc6979d1355d38dcfd90e8a3a5 Mon Sep 17 00:00:00 2001
From: Slava Pestov <slava@slava-pestovs-macbook-pro.local>
Date: Sat, 16 May 2009 08:54:14 -0500
Subject: [PATCH 12/23] Clean up pprint-use and related code to use manifests

---
 basis/prettyprint/prettyprint-docs.factor   |  9 ---
 basis/prettyprint/prettyprint.factor        | 70 ++-------------------
 basis/prettyprint/sections/sections.factor  | 28 ++++++---
 basis/see/see-docs.factor                   |  4 +-
 basis/see/see.factor                        |  4 +-
 basis/vocabs/prettyprint/prettyprint.factor |  9 ++-
 6 files changed, 36 insertions(+), 88 deletions(-)

diff --git a/basis/prettyprint/prettyprint-docs.factor b/basis/prettyprint/prettyprint-docs.factor
index 1af921d4f3..fbbece4602 100644
--- a/basis/prettyprint/prettyprint-docs.factor
+++ b/basis/prettyprint/prettyprint-docs.factor
@@ -161,10 +161,6 @@ $nl
 
 ABOUT: "prettyprint"
 
-HELP: with-pprint
-{ $values { "obj" object } { "quot" quotation } }
-{ $description "Sets up the prettyprinter and calls the quotation in a new scope. The quotation should add sections to the top-level block. When the quotation returns, the top-level block is printed to " { $link output-stream } "." } ;
-
 HELP: pprint
 { $values { "obj" object } }
 { $description "Prettyprints an object to " { $link output-stream } ". Output is influenced by many variables; see " { $link "prettyprint-variables" } "." }
@@ -225,8 +221,3 @@ HELP: .r
 
 HELP: .s
 { $description "Displays the contents of the data stack, with the top of the stack printed first." } ;
-
-HELP: in.
-{ $values { "vocab" "a vocabulary specifier" } }
-{ $description "Prettyprints a " { $snippet "IN:" } " declaration." }
-$prettyprinting-note ;
\ No newline at end of file
diff --git a/basis/prettyprint/prettyprint.factor b/basis/prettyprint/prettyprint.factor
index 2286417dd1..99913a803a 100644
--- a/basis/prettyprint/prettyprint.factor
+++ b/basis/prettyprint/prettyprint.factor
@@ -4,78 +4,16 @@ USING: arrays accessors assocs colors combinators grouping io
 io.streams.string io.styles kernel make math math.parser namespaces
 parser prettyprint.backend prettyprint.config prettyprint.custom
 prettyprint.sections quotations sequences sorting strings vocabs
-vocabs.parser words sets ;
+vocabs.prettyprint words sets ;
 IN: prettyprint
 
-<PRIVATE
-
-: make-pprint ( obj quot -- block in use )
-    [
-        0 position set
-        H{ } clone pprinter-use set
-        V{ } clone recursion-check set
-        V{ } clone pprinter-stack set
-        over <object
-        call
-        pprinter-block
-        pprinter-in get
-        pprinter-use get keys
-    ] with-scope ; inline
-
-: with-pprint ( obj quot -- )
-    make-pprint 2drop do-pprint ; inline
-
-: pprint-vocab ( vocab -- )
-    dup vocab present-text ;
-
-: write-in ( vocab -- )
-    [ \ IN: pprint-word pprint-vocab ] with-pprint ;
-
-: in. ( vocab -- )
-    [ write-in ] when* ;
-
-: use. ( seq -- )
-    [
-        natural-sort [
-            \ USING: pprint-word
-            [ pprint-vocab ] each
-            \ ; pprint-word
-        ] with-pprint
-    ] unless-empty ;
-
-: use/in. ( in use -- )
-    over "syntax" 2array diff
-    [ nip use. ]
-    [ empty? not and [ nl ] when ]
-    [ drop in. ]
-    2tri ;
-
-: vocab-names ( words -- vocabs )
-    dictionary get
-    [ [ words>> eq? nip ] with assoc-find 2drop ] curry map sift ;
-
-: prelude. ( -- )
-    in get use get vocab-names prune in get ".private" append swap remove use/in. ;
-
-[
-    nl
-    { { font-style bold } { font-name "sans-serif" } } [
-        "Restarts were invoked adding vocabularies to the search path." print
-        "To avoid doing this in the future, add the following USING:" print
-        "and IN: forms at the top of the source file:" print nl
-    ] with-style
-    { { page-color T{ rgba f 0.8 0.8 0.8 1.0 } } } [ prelude. ] with-nesting
-    nl nl
-] print-use-hook set-global
-
-PRIVATE>
-
 : with-use ( obj quot -- )
-    make-pprint [ use/in. ] [ empty? not or [ nl ] when ] 2bi
+    make-pprint (pprint-manifest
+    [ pprint-manifest) ] [ [ drop nl ] unless-empty ] bi
     do-pprint ; inline
 
 : with-in ( obj quot -- )
-    make-pprint drop [ write-in bl ] when* do-pprint ; inline
+    make-pprint current-vocab>> [ pprint-in bl ] when* do-pprint ; inline
 
 : pprint ( obj -- ) [ pprint* ] with-pprint ;
 
diff --git a/basis/prettyprint/sections/sections.factor b/basis/prettyprint/sections/sections.factor
index f72c426533..b4eb40757d 100644
--- a/basis/prettyprint/sections/sections.factor
+++ b/basis/prettyprint/sections/sections.factor
@@ -1,9 +1,9 @@
-! Copyright (C) 2003, 2008 Slava Pestov.
+! Copyright (C) 2003, 2009 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: arrays generic hashtables io kernel math assocs
 namespaces make sequences strings io.styles vectors words
 prettyprint.config splitting classes continuations
-accessors sets ;
+accessors sets vocabs.parser combinators vocabs ;
 IN: prettyprint.sections
 
 ! State
@@ -19,8 +19,16 @@ TUPLE: pprinter last-newline line-count indent ;
 
 : <pprinter> ( -- pprinter ) 0 1 0 pprinter boa ;
 
+: (record-vocab) ( vocab -- )
+    dup pprinter-in get dup [ vocab-name ] when =
+    [ drop ] [ pprinter-use get conjoin ] if ;
+
 : record-vocab ( word -- )
-    vocabulary>> [ pprinter-use get conjoin ] when* ;
+    vocabulary>> {
+        { f [ ] }
+        { "syntax" [ ] }
+        [ (record-vocab) ]
+    } case ;
 
 ! Utility words
 : line-limit? ( -- ? )
@@ -327,7 +335,14 @@ M: block long-section ( block -- )
         ] each
     ] if-nonempty ;
 
-: make-pprint ( obj quot -- block in use )
+: pprinter-manifest ( -- manifest )
+    <manifest>
+    [ [ pprinter-use get keys >vector ] dip (>>search-vocabs) ]
+    [ [ pprinter-in get ] dip (>>current-vocab) ]
+    [ ]
+    tri ;
+
+: make-pprint ( obj quot -- block manifest )
     [
         0 position set
         H{ } clone pprinter-use set
@@ -336,9 +351,8 @@ M: block long-section ( block -- )
         over <object
         call
         pprinter-block
-        pprinter-in get
-        pprinter-use get keys
+        pprinter-manifest
     ] with-scope ; inline
 
 : with-pprint ( obj quot -- )
-    make-pprint 2drop do-pprint ; inline
\ No newline at end of file
+    make-pprint drop do-pprint ; inline
\ No newline at end of file
diff --git a/basis/see/see-docs.factor b/basis/see/see-docs.factor
index 2423950d86..1674c9a747 100644
--- a/basis/see/see-docs.factor
+++ b/basis/see/see-docs.factor
@@ -1,6 +1,6 @@
+USING: help.markup help.syntax strings definitions generic words classes ;
+FROM: prettyprint.sections => with-pprint ;
 IN: see
-USING: help.markup help.syntax strings prettyprint.private
-definitions generic words classes ;
 
 HELP: synopsis
 { $values { "defspec" "a definition specifier" } { "str" string } }
diff --git a/basis/see/see.factor b/basis/see/see.factor
index 37153b5229..d2515a2e81 100644
--- a/basis/see/see.factor
+++ b/basis/see/see.factor
@@ -7,7 +7,7 @@ generic.single generic.standard generic.hook io io.pathnames
 io.streams.string io.styles kernel make namespaces prettyprint
 prettyprint.backend prettyprint.config prettyprint.custom
 prettyprint.sections sequences sets sorting strings summary words
-words.symbol words.constant words.alias ;
+words.symbol words.constant words.alias vocabs ;
 IN: see
 
 GENERIC: synopsis* ( defspec -- )
@@ -44,7 +44,7 @@ M: word print-stack-effect? drop t ;
 <PRIVATE
 
 : seeing-word ( word -- )
-    vocabulary>> pprinter-in set ;
+    vocabulary>> vocab pprinter-in set ;
 
 : word-synopsis ( word -- )
     {
diff --git a/basis/vocabs/prettyprint/prettyprint.factor b/basis/vocabs/prettyprint/prettyprint.factor
index 2ada653af1..0e150ef07a 100644
--- a/basis/vocabs/prettyprint/prettyprint.factor
+++ b/basis/vocabs/prettyprint/prettyprint.factor
@@ -64,15 +64,20 @@ M: rename pprint-qualified ( rename -- )
 
 PRIVATE>
 
-: pprint-manifest ( manifest -- )
+: (pprint-manifest ( manifest -- quots )
     [
         [ search-vocabs>> [ '[ _ pprint-using ] , ] unless-empty ]
         [ qualified-vocabs>> [ extra-words? not ] filter [ '[ _ pprint-qualified ] , ] each ]
         [ current-vocab>> [ '[ _ pprint-in ] , ] when* ]
         tri
-    ] { } make
+    ] { } make ;
+
+: pprint-manifest) ( quots -- )
     [ nl ] [ call( -- ) ] interleave ;
 
+: pprint-manifest ( manifest -- )
+    (pprint-manifest pprint-manifest) ;
+
 [
     nl
     { { font-style bold } { font-name "sans-serif" } } [

From ba07afd3836248bc47b7a07209bfb8bf35924413 Mon Sep 17 00:00:00 2001
From: Slava Pestov <slava@slava-pestovs-macbook-pro.local>
Date: Sat, 16 May 2009 08:56:09 -0500
Subject: [PATCH 13/23] Change how byte-vectors prettyprint

---
 basis/prettyprint/backend/backend.factor | 1 +
 1 file changed, 1 insertion(+)

diff --git a/basis/prettyprint/backend/backend.factor b/basis/prettyprint/backend/backend.factor
index 3dcd7fb0ed..ee8d2dfea3 100644
--- a/basis/prettyprint/backend/backend.factor
+++ b/basis/prettyprint/backend/backend.factor
@@ -188,6 +188,7 @@ M: tuple >pprint-sequence
     [ 1array ] [ [ f 2array ] dip append ] if-empty ;
 
 M: object pprint-narrow? drop f ;
+M: byte-vector pprint-narrow? drop f ;
 M: array pprint-narrow? drop t ;
 M: vector pprint-narrow? drop t ;
 M: hashtable pprint-narrow? drop t ;

From 93509cdcecddffad7a794d7ff927e1ae761eb34a Mon Sep 17 00:00:00 2001
From: Slava Pestov <slava@slava-pestovs-macbook-pro.local>
Date: Sat, 16 May 2009 08:58:10 -0500
Subject: [PATCH 14/23] Fix cpu.ppc for strict vocabulary search path semantics

---
 basis/cpu/ppc/bootstrap.factor | 1 +
 basis/cpu/ppc/ppc.factor       | 1 +
 2 files changed, 2 insertions(+)

diff --git a/basis/cpu/ppc/bootstrap.factor b/basis/cpu/ppc/bootstrap.factor
index b09938f4b9..cbb914121e 100644
--- a/basis/cpu/ppc/bootstrap.factor
+++ b/basis/cpu/ppc/bootstrap.factor
@@ -4,6 +4,7 @@ USING: bootstrap.image.private kernel kernel.private namespaces
 system cpu.ppc.assembler compiler.codegen.fixup compiler.units
 compiler.constants math math.private layouts words
 vocabs slots.private locals.backend ;
+FROM: cpu.ppc.assembler => B ;
 IN: bootstrap.ppc
 
 4 \ cell set
diff --git a/basis/cpu/ppc/ppc.factor b/basis/cpu/ppc/ppc.factor
index dc7108b3a1..617a7c5141 100644
--- a/basis/cpu/ppc/ppc.factor
+++ b/basis/cpu/ppc/ppc.factor
@@ -7,6 +7,7 @@ cpu.ppc.assembler cpu.ppc.assembler.backend literals compiler.cfg.registers
 compiler.cfg.instructions compiler.constants compiler.codegen
 compiler.codegen.fixup compiler.cfg.intrinsics
 compiler.cfg.stack-frame compiler.units ;
+FROM: cpu.ppc.assembler => B ;
 IN: cpu.ppc
 
 ! PowerPC register assignments:

From 90560d39599cfdc97ab936da723946851daa3d21 Mon Sep 17 00:00:00 2001
From: Slava Pestov <slava@slava-pestovs-macbook-pro.local>
Date: Sat, 16 May 2009 09:34:42 -0500
Subject: [PATCH 15/23] Better presentation for ambiguous-use-error, fix
 ui.tools.listener now that 'search' can throw, make USE: and UNUSE: ignore
 dupes

---
 basis/debugger/debugger.factor          | 11 ++++-
 basis/ui/tools/listener/listener.factor |  4 +-
 core/parser/parser-tests.factor         | 14 +++++-
 core/vocabs/parser/parser.factor        | 64 +++++++++++++++++--------
 4 files changed, 69 insertions(+), 24 deletions(-)

diff --git a/basis/debugger/debugger.factor b/basis/debugger/debugger.factor
index bb0268f048..7994c3ed96 100644
--- a/basis/debugger/debugger.factor
+++ b/basis/debugger/debugger.factor
@@ -251,8 +251,15 @@ M: already-disposed summary drop "Attempting to operate on disposed object" ;
 M: no-current-vocab summary
     drop "Not in a vocabulary; IN: form required" ;
 
-M: no-word-error error.
-    "No word named ``" write name>> write "'' found in current vocabulary search path" print ;
+M: no-word-error summary
+    name>> "No word named ``" "'' found in current vocabulary search path" surround ;
+
+M: no-word-error error. summary print ;
+
+M: ambiguous-use-error summary
+    words>> first name>> "More than one vocabulary defines a word named ``" "''" surround ;
+
+M: ambiguous-use-error error. summary print ;
 
 M: staging-violation summary
     drop
diff --git a/basis/ui/tools/listener/listener.factor b/basis/ui/tools/listener/listener.factor
index 2e89482c3d..e12e59d259 100644
--- a/basis/ui/tools/listener/listener.factor
+++ b/basis/ui/tools/listener/listener.factor
@@ -55,7 +55,9 @@ M: vocab-completion (word-at-caret)
     drop dup vocab-exists? [ >vocab-link ] [ drop f ] if ;
 
 M: word-completion (word-at-caret)
-    manifest>> dup [ search-manifest ] [ 2drop f ] if ;
+    manifest>> dup [
+        '[ _ _ search-manifest ] [ drop f ] recover
+    ] [ 2drop f ] if ;
 
 M: char-completion (word-at-caret)
     2drop f ;
diff --git a/core/parser/parser-tests.factor b/core/parser/parser-tests.factor
index 16f08d474a..5cbcc14184 100644
--- a/core/parser/parser-tests.factor
+++ b/core/parser/parser-tests.factor
@@ -608,4 +608,16 @@ EXCLUDE: qualified.tests.bar => x ;
 
 [ t ] [
     "z" "parser.tests.forward-ref-3" lookup def>> [ vocabulary>> ] map all-equal?
-] unit-test
\ No newline at end of file
+] unit-test
+
+[ [ dup ] ] [
+    "USE: kernel dup" <string-reader> "unuse-test" parse-stream
+] unit-test
+
+[
+    "dup" <string-reader> "unuse-test" parse-stream
+] [ error>> error>> error>> no-word-error? ] must-fail-with
+
+[
+    "USE: kernel UNUSE: kernel dup" <string-reader> "unuse-test" parse-stream
+] [ error>> error>> error>> no-word-error? ] must-fail-with
\ No newline at end of file
diff --git a/core/vocabs/parser/parser.factor b/core/vocabs/parser/parser.factor
index 43451b4c86..ba4fb265c3 100644
--- a/core/vocabs/parser/parser.factor
+++ b/core/vocabs/parser/parser.factor
@@ -8,8 +8,21 @@ IN: vocabs.parser
 
 ERROR: no-word-error name ;
 
+: word-restarts ( possibilities -- restarts )
+    natural-sort
+    [ [ vocabulary>> "Use the " " vocabulary" surround ] keep ] { } map>assoc ;
+
+: word-restarts-with-defer ( name possibilities -- restarts )
+    word-restarts
+    swap "Defer word in current vocabulary" swap 2array
+    suffix ;
+
+: <no-word-error> ( name possibilities -- error restarts )
+    [ drop \ no-word-error boa ] [ word-restarts-with-defer ] 2bi ;
+
 TUPLE: manifest
 current-vocab
+{ search-vocab-names hashtable }
 { search-vocabs vector }
 { qualified-vocabs vector }
 { extra-words vector }
@@ -17,6 +30,7 @@ current-vocab
 
 : <manifest> ( -- manifest )
     manifest new
+        H{ } clone >>search-vocab-names
         V{ } clone >>search-vocabs
         V{ } clone >>qualified-vocabs
         V{ } clone >>extra-words
@@ -24,6 +38,7 @@ current-vocab
 
 M: manifest clone
     call-next-method
+        [ clone ] change-search-vocab-names
         [ clone ] change-search-vocabs
         [ clone ] change-qualified-vocabs
         [ clone ] change-extra-words
@@ -40,12 +55,10 @@ C: <extra-words> extra-words
 
 : clear-manifest ( -- )
     manifest get
+    [ search-vocab-names>> clear-assoc ]
     [ search-vocabs>> delete-all ]
     [ qualified-vocabs>> delete-all ]
-    bi ;
-
-: (use-vocab) ( vocab -- vocab seq )
-    load-vocab manifest get search-vocabs>> ;
+    tri ;
 
 : (add-qualified) ( qualified -- )
     manifest get qualified-vocabs>> push ;
@@ -87,19 +100,33 @@ TUPLE: no-current-vocab ;
     manifest get current-vocab>> vocab-name ".private" ?tail
     [ set-current-vocab ] [ drop ] if ;
 
-: use-vocab ( vocab -- ) (use-vocab) push ;
+: using-vocab? ( vocab -- ? )
+    vocab-name manifest get search-vocab-names>> key? ;
+
+: use-vocab ( vocab -- )
+    dup using-vocab?
+    [ drop ] [
+        manifest get
+        [ [ vocab-name ] dip search-vocab-names>> conjoin ]
+        [ [ load-vocab ] dip search-vocabs>> push ]
+        2bi
+    ] if ;
 
 : auto-use-vocab ( vocab -- )
     [ use-vocab ] [ manifest get auto-used>> push ] bi ;
 
 : auto-used? ( -- ? ) manifest get auto-used>> length 0 > ;
 
-: unuse-vocab ( vocab -- ) (use-vocab) delq ;
+: unuse-vocab ( vocab -- )
+    dup using-vocab? [
+        manifest get
+        [ [ vocab-name ] dip search-vocab-names>> delete-at ]
+        [ [ load-vocab ] dip search-vocabs>> delq ]
+        2bi
+    ] [ drop ] if ;
 
 : only-use-vocabs ( vocabs -- )
-    clear-manifest
-    [ vocab ] V{ } map-as sift
-    manifest get search-vocabs>> push-all ;
+    clear-manifest [ vocab ] filter [ use-vocab ] each ;
 
 TUPLE: qualified vocab prefix words ;
 
@@ -141,7 +168,10 @@ TUPLE: rename word vocab words ;
 
 : unuse-words ( assoc -- ) (use-words) delete ;
 
-ERROR: ambiguous-use-error words ;
+TUPLE: ambiguous-use-error words ;
+
+: <ambiguous-use-error> ( words -- error restarts )
+    [ \ ambiguous-use-error boa ] [ word-restarts ] bi ;
 
 <PRIVATE
 
@@ -154,7 +184,10 @@ ERROR: ambiguous-use-error words ;
     (vocab-search) {
         { 0 [ drop f ] }
         { 1 [ first ] }
-        [ drop ambiguous-use-error ]
+        [
+            drop <ambiguous-use-error> throw-restarts
+            dup [ vocabulary>> ] [ name>> 1array ] bi add-words-from
+        ]
     } case ;
 
 : qualified-search ( name manifest -- word/f )
@@ -168,12 +201,3 @@ PRIVATE>
 
 : search ( name -- word/f )
     manifest get search-manifest ;
-
-: word-restarts ( name possibilities -- restarts )
-    natural-sort
-    [ [ vocabulary>> "Use the " " vocabulary" surround ] keep ] { } map>assoc
-    swap "Defer word in current vocabulary" swap 2array
-    suffix ;
-
-: <no-word-error> ( name possibilities -- error restarts )
-    [ drop \ no-word-error boa ] [ word-restarts ] 2bi ;

From 35ccf0231e73c99e809c91177091cffcf6025912 Mon Sep 17 00:00:00 2001
From: Slava Pestov <slava@slava-pestovs-macbook-pro.local>
Date: Sat, 16 May 2009 09:40:17 -0500
Subject: [PATCH 16/23] Factor out parser note code into parser.notes
 vocabulary, and print a note if a using list contains duplicates

---
 core/classes/tuple/parser/parser.factor |  2 +-
 core/parser/notes/authors.txt           |  1 +
 core/parser/notes/notes.factor          | 18 ++++++++++++++++++
 core/parser/parser.factor               | 16 +---------------
 core/vocabs/parser/parser.factor        |  5 +++--
 5 files changed, 24 insertions(+), 18 deletions(-)
 create mode 100644 core/parser/notes/authors.txt
 create mode 100644 core/parser/notes/notes.factor

diff --git a/core/classes/tuple/parser/parser.factor b/core/classes/tuple/parser/parser.factor
index 85a6249dd3..efb77e3274 100644
--- a/core/classes/tuple/parser/parser.factor
+++ b/core/classes/tuple/parser/parser.factor
@@ -2,7 +2,7 @@
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors kernel sets namespaces make sequences parser
 lexer combinators words classes.parser classes.tuple arrays
-slots math assocs ;
+slots math assocs parser.notes ;
 IN: classes.tuple.parser
 
 : slot-names ( slots -- seq )
diff --git a/core/parser/notes/authors.txt b/core/parser/notes/authors.txt
new file mode 100644
index 0000000000..d4f5d6b3ae
--- /dev/null
+++ b/core/parser/notes/authors.txt
@@ -0,0 +1 @@
+Slava Pestov
\ No newline at end of file
diff --git a/core/parser/notes/notes.factor b/core/parser/notes/notes.factor
new file mode 100644
index 0000000000..3f702d375d
--- /dev/null
+++ b/core/parser/notes/notes.factor
@@ -0,0 +1,18 @@
+! Copyright (C) 2009 Slava Pestov.
+! See http://factorcode.org/license.txt for BSD license.
+USING: namespaces kernel source-files lexer accessors io math.parser ;
+IN: parser.notes
+
+SYMBOL: parser-notes
+
+t parser-notes set-global
+
+: parser-notes? ( -- ? )
+    parser-notes get "quiet" get not and ;
+
+: note. ( str -- )
+    parser-notes? [
+        file get [ path>> write ":" write ] when* 
+        lexer get [ line>> number>string write ": " write ] when*
+        "Note:" print dup print
+    ] when drop ;
\ No newline at end of file
diff --git a/core/parser/parser.factor b/core/parser/parser.factor
index eb8d77959e..8d52dcaa2c 100644
--- a/core/parser/parser.factor
+++ b/core/parser/parser.factor
@@ -5,7 +5,7 @@ sequences strings vectors words words.symbol quotations io
 combinators sorting splitting math.parser effects continuations
 io.files vocabs io.encodings.utf8 source-files classes
 hashtables compiler.units accessors sets lexer vocabs.parser
-effects.parser slots ;
+effects.parser slots parser.notes ;
 IN: parser
 
 : location ( -- loc )
@@ -15,20 +15,6 @@ IN: parser
 : save-location ( definition -- )
     location remember-definition ;
 
-SYMBOL: parser-notes
-
-t parser-notes set-global
-
-: parser-notes? ( -- ? )
-    parser-notes get "quiet" get not and ;
-
-: note. ( str -- )
-    parser-notes? [
-        file get [ path>> write ":" write ] when* 
-        lexer get [ line>> number>string write ": " write ] when*
-        "Note:" print dup print
-    ] when drop ;
-
 M: parsing-word stack-effect drop (( parsed -- parsed )) ;
 
 : create-in ( str -- word )
diff --git a/core/vocabs/parser/parser.factor b/core/vocabs/parser/parser.factor
index ba4fb265c3..45084ae8ff 100644
--- a/core/vocabs/parser/parser.factor
+++ b/core/vocabs/parser/parser.factor
@@ -3,7 +3,8 @@
 ! See http://factorcode.org/license.txt for BSD license.
 USING: assocs hashtables kernel namespaces sequences
 sets strings vocabs sorting accessors arrays compiler.units
-combinators vectors splitting continuations math ;
+combinators vectors splitting continuations math
+parser.notes ;
 IN: vocabs.parser
 
 ERROR: no-word-error name ;
@@ -105,7 +106,7 @@ TUPLE: no-current-vocab ;
 
 : use-vocab ( vocab -- )
     dup using-vocab?
-    [ drop ] [
+    [ vocab-name "Already using ``" "'' vocabulary" surround note. ] [
         manifest get
         [ [ vocab-name ] dip search-vocab-names>> conjoin ]
         [ [ load-vocab ] dip search-vocabs>> push ]

From 3ff291cc920c64bb7ac35b972c84123b1bec343c Mon Sep 17 00:00:00 2001
From: Slava Pestov <slava@slava-pestovs-macbook-pro.local>
Date: Sat, 16 May 2009 09:43:01 -0500
Subject: [PATCH 17/23] help.lint: don't use mutable vocab tuple as key in
 lint-failures hash

---
 basis/help/lint/lint.factor | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/basis/help/lint/lint.factor b/basis/help/lint/lint.factor
index 7a5b482270..08cf4b2cd4 100755
--- a/basis/help/lint/lint.factor
+++ b/basis/help/lint/lint.factor
@@ -66,11 +66,12 @@ PRIVATE>
     ] check-something ;
 
 : check-about ( vocab -- )
-    dup '[ _ vocab-help [ article drop ] when* ] check-something ;
+    vocab-link boa dup
+    '[ _ vocab-help [ article drop ] when* ] check-something ;
 
 : check-vocab ( vocab -- )
     "Checking " write dup write "..." print
-    [ vocab check-about ]
+    [ check-about ]
     [ words [ check-word ] each ]
     [ vocab-articles get at [ check-article ] each ]
     tri ;

From 94884dfd18300063653a2562334aeb0da6f266fa Mon Sep 17 00:00:00 2001
From: Slava Pestov <slava@slava-pestovs-macbook-pro.local>
Date: Sat, 16 May 2009 09:48:58 -0500
Subject: [PATCH 18/23] Fix more usings

---
 basis/eval/eval.factor                   | 2 +-
 basis/prettyprint/backend/backend.factor | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/basis/eval/eval.factor b/basis/eval/eval.factor
index 4c5b9e8cf9..c4eab2d6ab 100644
--- a/basis/eval/eval.factor
+++ b/basis/eval/eval.factor
@@ -1,6 +1,6 @@
 ! Copyright (C) 2008, 2009 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: splitting parser compiler.units kernel namespaces
+USING: splitting parser parser.notes compiler.units kernel namespaces
 debugger io.streams.string fry combinators effects.parser ;
 IN: eval
 
diff --git a/basis/prettyprint/backend/backend.factor b/basis/prettyprint/backend/backend.factor
index ee8d2dfea3..27416e0f89 100644
--- a/basis/prettyprint/backend/backend.factor
+++ b/basis/prettyprint/backend/backend.factor
@@ -1,6 +1,6 @@
 ! Copyright (C) 2003, 2009 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors arrays byte-arrays byte-vectors generic hashtables io
+USING: accessors arrays byte-arrays byte-vectors generic hashtables
 assocs kernel math namespaces make sequences strings sbufs vectors
 words prettyprint.config prettyprint.custom prettyprint.sections
 quotations io io.pathnames io.styles math.parser effects classes.tuple

From 306d3c3b32314ce76e2213475330d38bc9e7f85a Mon Sep 17 00:00:00 2001
From: Slava Pestov <slava@slava-pestovs-macbook-pro.local>
Date: Sat, 16 May 2009 09:56:09 -0500
Subject: [PATCH 19/23] Docs for parser.notes

---
 core/parser/notes/notes-docs.factor | 10 ++++++++++
 core/parser/parser-docs.factor      |  7 -------
 2 files changed, 10 insertions(+), 7 deletions(-)
 create mode 100644 core/parser/notes/notes-docs.factor

diff --git a/core/parser/notes/notes-docs.factor b/core/parser/notes/notes-docs.factor
new file mode 100644
index 0000000000..f9a86c6934
--- /dev/null
+++ b/core/parser/notes/notes-docs.factor
@@ -0,0 +1,10 @@
+USING: help.markup help.syntax io ;
+IN: parser.notes
+
+HELP: parser-notes
+{ $var-description "A boolean controlling whether the parser will print various notes. Switched on by default. If a source file is being run for its effect on " { $link output-stream } ", this variable should be switched off, to prevent parser notes from polluting the output." } ;
+
+HELP: parser-notes?
+{ $values { "?" "a boolean" } }
+{ $description "Tests if the parser will print various notes and warnings. To disable parser notes, either set " { $link parser-notes } " to " { $link f } ", or pass the " { $snippet "-quiet" } " command line switch." } ;
+
diff --git a/core/parser/parser-docs.factor b/core/parser/parser-docs.factor
index ea6a136b95..ec0810509b 100644
--- a/core/parser/parser-docs.factor
+++ b/core/parser/parser-docs.factor
@@ -110,13 +110,6 @@ HELP: save-location
 { $values { "definition" "a definition specifier" } }
 { $description "Saves the location of a definition and associates this definition with the current source file." } ;
 
-HELP: parser-notes
-{ $var-description "A boolean controlling whether the parser will print various notes. Switched on by default. If a source file is being run for its effect on " { $link output-stream } ", this variable should be switched off, to prevent parser notes from polluting the output." } ;
-
-HELP: parser-notes?
-{ $values { "?" "a boolean" } }
-{ $description "Tests if the parser will print various notes and warnings. To disable parser notes, either set " { $link parser-notes } " to " { $link f } ", or pass the " { $snippet "-quiet" } " command line switch." } ;
-
 HELP: bad-number
 { $error-description "Indicates the parser encountered an invalid numeric literal." } ;
 

From 7c705c4db4dda412a60a90a046b973eb9a5db00f Mon Sep 17 00:00:00 2001
From: Slava Pestov <slava@slava-pestovs-macbook-pro.local>
Date: Sat, 16 May 2009 10:02:48 -0500
Subject: [PATCH 20/23] Comment out JPEG code until we figure out if we want
 default bootstrap to depend on BLAS or not

---
 basis/images/loader/loader.factor | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/basis/images/loader/loader.factor b/basis/images/loader/loader.factor
index 27b726f3c0..d86b275635 100644
--- a/basis/images/loader/loader.factor
+++ b/basis/images/loader/loader.factor
@@ -2,7 +2,7 @@
 ! See http://factorcode.org/license.txt for BSD license.
 USING: constructors kernel splitting unicode.case combinators
 accessors images.bitmap images.tiff images io.pathnames
-images.jpeg images.png ;
+images.png ;
 IN: images.loader
 
 ERROR: unknown-image-extension extension ;
@@ -12,8 +12,8 @@ ERROR: unknown-image-extension extension ;
         { "bmp" [ bitmap-image ] }
         { "tif" [ tiff-image ] }
         { "tiff" [ tiff-image ] }
-        { "jpg" [ jpeg-image ] }
-        { "jpeg" [ jpeg-image ] }
+        ! { "jpg" [ jpeg-image ] }
+        ! { "jpeg" [ jpeg-image ] }
         { "png" [ png-image ] }
         [ unknown-image-extension ]
     } case ;

From a0eb60906d10dbf878f51b903a013b57fd738478 Mon Sep 17 00:00:00 2001
From: Slava Pestov <slava@slava-pestovs-macbook-pro.local>
Date: Sat, 16 May 2009 10:45:17 -0500
Subject: [PATCH 21/23] Fix even more usings

---
 basis/alien/structs/structs-docs.factor       |  5 ++---
 basis/bootstrap/image/image.factor            | 19 +++++++++----------
 basis/cocoa/messages/messages.factor          |  4 ++--
 basis/core-foundation/data/data.factor        |  3 +--
 basis/io/sockets/unix/unix.factor             |  8 ++++----
 basis/peg/peg.factor                          |  2 +-
 basis/tools/memory/memory.factor              |  4 ++--
 basis/ui/text/text.factor                     |  2 +-
 basis/ui/tools/debugger/debugger.factor       | 11 +++++------
 basis/unicode/data/data.factor                |  2 +-
 basis/unix/process/process.factor             |  6 +++---
 core/classes/classes-docs.factor              |  4 ++--
 .../intersection/intersection-docs.factor     |  2 +-
 core/classes/union/union-docs.factor          |  4 ++--
 core/slots/slots-docs.factor                  |  4 ++--
 core/syntax/syntax-docs.factor                |  7 +++----
 16 files changed, 41 insertions(+), 46 deletions(-)

diff --git a/basis/alien/structs/structs-docs.factor b/basis/alien/structs/structs-docs.factor
index 62b8510d17..2f7a7eadc8 100644
--- a/basis/alien/structs/structs-docs.factor
+++ b/basis/alien/structs/structs-docs.factor
@@ -1,6 +1,5 @@
-USING: accessors alien.c-types strings help.markup help.syntax
-alien.syntax sequences io arrays kernel words assocs namespaces
-accessors ;
+USING: alien.c-types strings help.markup help.syntax alien.syntax
+sequences io arrays kernel words assocs namespaces ;
 IN: alien.structs
 
 ARTICLE: "c-structs" "C structure types"
diff --git a/basis/bootstrap/image/image.factor b/basis/bootstrap/image/image.factor
index 68c7b23302..d76588e4e4 100644
--- a/basis/bootstrap/image/image.factor
+++ b/basis/bootstrap/image/image.factor
@@ -1,15 +1,14 @@
 ! Copyright (C) 2004, 2009 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: alien arrays byte-arrays generic hashtables
-hashtables.private io io.binary io.files io.encodings.binary
-io.pathnames kernel kernel.private math namespaces make parser
-prettyprint sequences sequences.private strings sbufs vectors words
-quotations assocs system layouts splitting grouping growable classes
-classes.builtin classes.tuple classes.tuple.private vocabs
-vocabs.loader source-files definitions debugger quotations.private
-sequences.private combinators math.order math.private accessors
-slots.private generic.single.private compiler.units compiler.constants
-fry bootstrap.image.syntax ;
+USING: alien arrays byte-arrays generic hashtables hashtables.private
+io io.binary io.files io.encodings.binary io.pathnames kernel
+kernel.private math namespaces make parser prettyprint sequences
+strings sbufs vectors words quotations assocs system layouts splitting
+grouping growable classes classes.builtin classes.tuple
+classes.tuple.private vocabs vocabs.loader source-files definitions
+debugger quotations.private combinators math.order math.private
+accessors slots.private generic.single.private compiler.units
+compiler.constants fry bootstrap.image.syntax ;
 IN: bootstrap.image
 
 : arch ( os cpu -- arch )
diff --git a/basis/cocoa/messages/messages.factor b/basis/cocoa/messages/messages.factor
index fdd4ba81d7..a3fa788f20 100644
--- a/basis/cocoa/messages/messages.factor
+++ b/basis/cocoa/messages/messages.factor
@@ -2,9 +2,9 @@
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors alien alien.c-types alien.strings arrays assocs
 continuations combinators compiler compiler.alien stack-checker kernel
-math namespaces make parser quotations sequences strings words
+math namespaces make quotations sequences strings words
 cocoa.runtime io macros memoize io.encodings.utf8 effects libc
-libc.private parser lexer init core-foundation fry generalizations
+libc.private lexer init core-foundation fry generalizations
 specialized-arrays.direct.alien ;
 IN: cocoa.messages
 
diff --git a/basis/core-foundation/data/data.factor b/basis/core-foundation/data/data.factor
index c708eacecc..ef5973888e 100644
--- a/basis/core-foundation/data/data.factor
+++ b/basis/core-foundation/data/data.factor
@@ -1,7 +1,6 @@
 ! Copyright (C) 2008 Joe Groff.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: alien.c-types alien.syntax core-foundation.numbers kernel math
-sequences core-foundation.numbers ;
+USING: alien.c-types alien.syntax kernel math sequences ;
 IN: core-foundation.data
 
 TYPEDEF: void* CFDataRef
diff --git a/basis/io/sockets/unix/unix.factor b/basis/io/sockets/unix/unix.factor
index 6ba7ca2322..fe136cd887 100644
--- a/basis/io/sockets/unix/unix.factor
+++ b/basis/io/sockets/unix/unix.factor
@@ -1,10 +1,10 @@
 ! Copyright (C) 2004, 2008 Slava Pestov, Ivan Tikhonov. 
 ! See http://factorcode.org/license.txt for BSD license.
 USING: alien alien.c-types alien.strings generic kernel math threads
-sequences byte-arrays io.ports io.binary io.backend.unix
-io.streams.duplex io.backend io.ports io.pathnames io.files.private
-io.encodings.utf8 math.parser continuations libc combinators system
-accessors destructors unix locals init ;
+sequences byte-arrays io.binary io.backend.unix io.streams.duplex
+io.backend io.pathnames io.files.private io.encodings.utf8 math.parser
+continuations libc combinators system accessors destructors unix
+locals init ;
 
 EXCLUDE: namespaces => bind ;
 EXCLUDE: io => read write ;
diff --git a/basis/peg/peg.factor b/basis/peg/peg.factor
index c76ca7ac9c..12e6d59fc0 100644
--- a/basis/peg/peg.factor
+++ b/basis/peg/peg.factor
@@ -3,7 +3,7 @@
 USING: kernel sequences strings fry namespaces make math assocs
 io vectors arrays math.parser math.order combinators
 classes sets unicode.categories compiler.units parser words
-quotations effects memoize accessors locals effects splitting
+quotations memoize accessors locals splitting
 combinators.short-circuit generalizations ;
 IN: peg
 
diff --git a/basis/tools/memory/memory.factor b/basis/tools/memory/memory.factor
index 3d9166aafa..81785f7ea4 100644
--- a/basis/tools/memory/memory.factor
+++ b/basis/tools/memory/memory.factor
@@ -1,7 +1,7 @@
 ! Copyright (C) 2005, 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: kernel sequences vectors arrays generic assocs io math
-namespaces parser prettyprint strings io.styles vectors words
+USING: kernel sequences arrays generic assocs io math
+namespaces parser prettyprint strings io.styles words
 system sorting splitting grouping math.parser classes memory
 combinators fry ;
 IN: tools.memory
diff --git a/basis/ui/text/text.factor b/basis/ui/text/text.factor
index c1f05182e6..6d5c7e56a6 100755
--- a/basis/ui/text/text.factor
+++ b/basis/ui/text/text.factor
@@ -73,7 +73,7 @@ M: array draw-text
         ] with each
     ] do-matrix ;
 
-USING: vocabs.loader namespaces system combinators ;
+USING: vocabs.loader system combinators ;
 
 {
     { [ os macosx? ] [ "core-text" ] }
diff --git a/basis/ui/tools/debugger/debugger.factor b/basis/ui/tools/debugger/debugger.factor
index cf86ce4223..024442a264 100755
--- a/basis/ui/tools/debugger/debugger.factor
+++ b/basis/ui/tools/debugger/debugger.factor
@@ -1,12 +1,11 @@
 ! Copyright (C) 2006, 2009 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors arrays hashtables io kernel math models
-colors.constants namespaces sequences words continuations
-debugger prettyprint help editors fonts ui ui.commands ui.gestures
-ui.gadgets ui.pens.solid ui.gadgets.worlds ui.gadgets.packs
-ui.gadgets.buttons ui.gadgets.labels ui.gadgets.panes
-ui.gadgets.presentations ui.gadgets.viewports ui.gadgets.tables
-ui.gadgets.tracks ui.gadgets.scrollers ui.gadgets.panes
+colors.constants namespaces sequences words continuations debugger
+prettyprint help editors fonts ui ui.commands ui.gestures ui.gadgets
+ui.pens.solid ui.gadgets.worlds ui.gadgets.packs ui.gadgets.buttons
+ui.gadgets.labels ui.gadgets.presentations ui.gadgets.viewports
+ui.gadgets.tables ui.gadgets.tracks ui.gadgets.scrollers
 ui.gadgets.borders ui.gadgets.status-bar ui.tools.traceback
 ui.tools.inspector ui.tools.browser ui.debugger ;
 IN: ui.tools.debugger
diff --git a/basis/unicode/data/data.factor b/basis/unicode/data/data.factor
index 779ae64d48..318a56627b 100644
--- a/basis/unicode/data/data.factor
+++ b/basis/unicode/data/data.factor
@@ -2,7 +2,7 @@
 ! See http://factorcode.org/license.txt for BSD license.
 USING: combinators.short-circuit assocs math kernel sequences
 io.files hashtables quotations splitting grouping arrays io
-math.parser hash2 math.order byte-arrays words namespaces words
+math.parser hash2 math.order byte-arrays namespaces
 compiler.units parser io.encodings.ascii values interval-maps
 ascii sets combinators locals math.ranges sorting make
 strings.parser io.encodings.utf8 memoize simple-flat-file ;
diff --git a/basis/unix/process/process.factor b/basis/unix/process/process.factor
index 9819e50843..da8b1e63e3 100644
--- a/basis/unix/process/process.factor
+++ b/basis/unix/process/process.factor
@@ -1,6 +1,6 @@
-USING: kernel alien.c-types alien.strings sequences math alien.syntax unix
-vectors namespaces continuations threads assocs vectors
-io.backend.unix io.encodings.utf8 unix.utilities fry ;
+USING: kernel alien.c-types alien.strings sequences math alien.syntax
+unix namespaces continuations threads assocs io.backend.unix
+io.encodings.utf8 unix.utilities fry ;
 IN: unix.process
 
 ! Low-level Unix process launching utilities. These are used
diff --git a/core/classes/classes-docs.factor b/core/classes/classes-docs.factor
index f8a2ff415c..109a3b8089 100644
--- a/core/classes/classes-docs.factor
+++ b/core/classes/classes-docs.factor
@@ -1,6 +1,6 @@
 USING: help.markup help.syntax kernel kernel.private
-namespaces sequences words arrays layouts effects math
-layouts classes.private classes.union classes.mixin
+namespaces sequences words arrays effects math
+classes.private classes.union classes.mixin
 classes.predicate quotations ;
 IN: classes
 
diff --git a/core/classes/intersection/intersection-docs.factor b/core/classes/intersection/intersection-docs.factor
index e9ca706d63..fbd41f5407 100644
--- a/core/classes/intersection/intersection-docs.factor
+++ b/core/classes/intersection/intersection-docs.factor
@@ -1,5 +1,5 @@
 USING: generic help.markup help.syntax kernel kernel.private
-namespaces sequences words arrays layouts help effects math
+namespaces sequences words arrays help effects math
 layouts classes.private classes compiler.units ;
 IN: classes.intersection
 
diff --git a/core/classes/union/union-docs.factor b/core/classes/union/union-docs.factor
index 3d7312a889..4117010fff 100644
--- a/core/classes/union/union-docs.factor
+++ b/core/classes/union/union-docs.factor
@@ -1,6 +1,6 @@
 USING: generic help.markup help.syntax kernel kernel.private
-namespaces sequences words arrays layouts help effects math
-layouts classes.private classes compiler.units ;
+namespaces sequences words arrays help effects math
+classes.private classes compiler.units ;
 IN: classes.union
 
 ARTICLE: "unions" "Union classes"
diff --git a/core/slots/slots-docs.factor b/core/slots/slots-docs.factor
index 348e2ec2b2..eb0e07c71d 100644
--- a/core/slots/slots-docs.factor
+++ b/core/slots/slots-docs.factor
@@ -1,5 +1,5 @@
-USING: help.markup help.syntax generic kernel.private parser words
-kernel quotations namespaces sequences words arrays effects
+USING: help.markup help.syntax generic kernel.private parser
+kernel quotations namespaces sequences arrays effects
 generic.standard classes.builtin slots.private classes strings math
 assocs byte-arrays alien classes.tuple ;
 IN: slots
diff --git a/core/syntax/syntax-docs.factor b/core/syntax/syntax-docs.factor
index cd5a325b52..d408da4bc7 100644
--- a/core/syntax/syntax-docs.factor
+++ b/core/syntax/syntax-docs.factor
@@ -1,8 +1,7 @@
 USING: generic help.syntax help.markup kernel math parser words
-effects classes generic.standard classes.tuple generic.math
-generic.standard generic.single arrays io.pathnames vocabs.loader io
-sequences assocs words.symbol words.alias words.constant combinators 
-vocabs.parser ;
+effects classes classes.tuple generic.math generic.single arrays
+io.pathnames vocabs.loader io sequences assocs words.symbol
+words.alias words.constant combinators vocabs.parser ;
 IN: syntax
 
 ARTICLE: "parser-algorithm" "Parser algorithm"

From 142fddd530a3a7af59d904120036d41d6fd88b9a Mon Sep 17 00:00:00 2001
From: Slava Pestov <slava@factorcode.org>
Date: Sat, 16 May 2009 11:50:16 -0400
Subject: [PATCH 22/23] Fix usings on X11

---
 basis/io/files/info/unix/linux/linux.factor | 1 +
 basis/io/monitors/linux/linux.factor        | 2 +-
 basis/x11/xlib/xlib.factor                  | 3 ---
 3 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/basis/io/files/info/unix/linux/linux.factor b/basis/io/files/info/unix/linux/linux.factor
index 72401004ae..a8eb9b65a0 100644
--- a/basis/io/files/info/unix/linux/linux.factor
+++ b/basis/io/files/info/unix/linux/linux.factor
@@ -6,6 +6,7 @@ io.files.unix kernel math.order namespaces sequences sorting
 system unix unix.statfs.linux unix.statvfs.linux io.files.links
 specialized-arrays.direct.uint arrays io.files.info.unix assocs
 io.pathnames unix.types ;
+FROM: csv => delimiter ;
 IN: io.files.info.unix.linux
 
 TUPLE: linux-file-system-info < unix-file-system-info
diff --git a/basis/io/monitors/linux/linux.factor b/basis/io/monitors/linux/linux.factor
index e914f32a48..9097e7e864 100644
--- a/basis/io/monitors/linux/linux.factor
+++ b/basis/io/monitors/linux/linux.factor
@@ -1,7 +1,7 @@
 ! Copyright (C) 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: kernel io.backend io.monitors io.monitors.recursive
-io.files io.pathnames io.buffers io.monitors io.ports io.timeouts
+io.files io.pathnames io.buffers io.ports io.timeouts
 io.backend.unix io.encodings.utf8 unix.linux.inotify assocs
 namespaces make threads continuations init math math.bitwise
 sets alien alien.strings alien.c-types vocabs.loader accessors
diff --git a/basis/x11/xlib/xlib.factor b/basis/x11/xlib/xlib.factor
index 638f5c8d56..65338dc88b 100644
--- a/basis/x11/xlib/xlib.factor
+++ b/basis/x11/xlib/xlib.factor
@@ -447,9 +447,6 @@ X-FUNCTION: Status XDrawString (
 
 ! 8.7 - Transferring Images between Client and Server
 
-CONSTANT: XYBitmap 0
-CONSTANT: XYPixmap 1
-CONSTANT: ZPixmap  2
 CONSTANT: AllPlanes -1
 
 C-STRUCT: XImage-funcs

From a9c339e583ce9e879f1d48a0511a34654168409d Mon Sep 17 00:00:00 2001
From: Slava Pestov <slava@factorcode.org>
Date: Sat, 16 May 2009 11:20:08 -0500
Subject: [PATCH 23/23] Fix windows bootstrap

---
 basis/io/sockets/windows/nt/nt.factor   |  2 +-
 basis/ui/backend/windows/windows.factor |  4 ++--
 basis/windows/gdi32/gdi32.factor        |  1 +
 basis/windows/kernel32/kernel32.factor  |  2 --
 basis/windows/opengl32/opengl32.factor  | 30 -------------------------
 5 files changed, 4 insertions(+), 35 deletions(-)
 mode change 100644 => 100755 basis/io/sockets/windows/nt/nt.factor

diff --git a/basis/io/sockets/windows/nt/nt.factor b/basis/io/sockets/windows/nt/nt.factor
old mode 100644
new mode 100755
index 49a1b2ae63..6d082f953c
--- a/basis/io/sockets/windows/nt/nt.factor
+++ b/basis/io/sockets/windows/nt/nt.factor
@@ -1,6 +1,6 @@
 USING: alien alien.accessors alien.c-types byte-arrays
 continuations destructors io.ports io.timeouts io.sockets
-io.sockets io namespaces io.streams.duplex io.backend.windows
+io namespaces io.streams.duplex io.backend.windows
 io.sockets.windows io.backend.windows.nt windows.winsock kernel
 libc math sequences threads system combinators accessors ;
 IN: io.sockets.windows.nt
diff --git a/basis/ui/backend/windows/windows.factor b/basis/ui/backend/windows/windows.factor
index 1ca3e85232..e28776a51c 100755
--- a/basis/ui/backend/windows/windows.factor
+++ b/basis/ui/backend/windows/windows.factor
@@ -8,8 +8,8 @@ math.vectors namespaces make sequences strings vectors words
 windows.kernel32 windows.gdi32 windows.user32 windows.opengl32
 windows.messages windows.types windows.offscreen windows.nt
 threads libc combinators fry combinators.short-circuit continuations
-command-line shuffle opengl ui.render ascii math.bitwise locals
-accessors math.rectangles math.order ascii calendar
+command-line shuffle opengl ui.render math.bitwise locals
+accessors math.rectangles math.order calendar ascii
 io.encodings.utf16n windows.errors literals ui.pixel-formats 
 ui.pixel-formats.private memoize classes struct-arrays ;
 IN: ui.backend.windows
diff --git a/basis/windows/gdi32/gdi32.factor b/basis/windows/gdi32/gdi32.factor
index 0699c92be3..5187c3f660 100755
--- a/basis/windows/gdi32/gdi32.factor
+++ b/basis/windows/gdi32/gdi32.factor
@@ -233,6 +233,7 @@ CONSTANT: PFD_DRAW_TO_WINDOW 4
 CONSTANT: PFD_DRAW_TO_BITMAP 8
 CONSTANT: PFD_SUPPORT_GDI 16
 CONSTANT: PFD_SUPPORT_OPENGL 32
+CONSTANT: PFD_SUPPORT_DIRECTDRAW 8192
 CONSTANT: PFD_GENERIC_FORMAT 64
 CONSTANT: PFD_NEED_PALETTE 128
 CONSTANT: PFD_NEED_SYSTEM_PALETTE HEX: 00000100
diff --git a/basis/windows/kernel32/kernel32.factor b/basis/windows/kernel32/kernel32.factor
index e654b68bdc..38c63abc72 100755
--- a/basis/windows/kernel32/kernel32.factor
+++ b/basis/windows/kernel32/kernel32.factor
@@ -180,8 +180,6 @@ CONSTANT: SEC_COMMIT HEX: 08000000
 CONSTANT: SEC_NOCACHE HEX: 10000000
 ALIAS: MEM_IMAGE SEC_IMAGE
 
-CONSTANT: ERROR_ALREADY_EXISTS 183
-
 CONSTANT: FILE_MAP_ALL_ACCESS HEX: f001f
 CONSTANT: FILE_MAP_READ   4
 CONSTANT: FILE_MAP_WRITE  2
diff --git a/basis/windows/opengl32/opengl32.factor b/basis/windows/opengl32/opengl32.factor
index 4173332dc3..63f705263c 100755
--- a/basis/windows/opengl32/opengl32.factor
+++ b/basis/windows/opengl32/opengl32.factor
@@ -5,36 +5,6 @@ math math.bitwise windows.types init assocs splitting
 sequences libc opengl.gl opengl.gl.extensions opengl.gl.windows ;
 IN: windows.opengl32
 
-! PIXELFORMATDESCRIPTOR flags
-CONSTANT: PFD_DOUBLEBUFFER            HEX: 00000001
-CONSTANT: PFD_STEREO                  HEX: 00000002
-CONSTANT: PFD_DRAW_TO_WINDOW          HEX: 00000004
-CONSTANT: PFD_DRAW_TO_BITMAP          HEX: 00000008
-CONSTANT: PFD_SUPPORT_GDI             HEX: 00000010
-CONSTANT: PFD_SUPPORT_OPENGL          HEX: 00000020
-CONSTANT: PFD_GENERIC_FORMAT          HEX: 00000040
-CONSTANT: PFD_NEED_PALETTE            HEX: 00000080
-CONSTANT: PFD_NEED_SYSTEM_PALETTE     HEX: 00000100
-CONSTANT: PFD_SWAP_EXCHANGE           HEX: 00000200
-CONSTANT: PFD_SWAP_COPY               HEX: 00000400
-CONSTANT: PFD_SWAP_LAYER_BUFFERS      HEX: 00000800
-CONSTANT: PFD_GENERIC_ACCELERATED     HEX: 00001000
-CONSTANT: PFD_SUPPORT_DIRECTDRAW      HEX: 00002000
-
-! PIXELFORMATDESCRIPTOR flags for use in ChoosePixelFormat only
-CONSTANT: PFD_DEPTH_DONTCARE          HEX: 20000000
-CONSTANT: PFD_DOUBLEBUFFER_DONTCARE   HEX: 40000000
-CONSTANT: PFD_STEREO_DONTCARE         HEX: 80000000
-
-! pixel types
-CONSTANT: PFD_TYPE_RGBA        0
-CONSTANT: PFD_TYPE_COLORINDEX  1
- 
-! layer types
-CONSTANT: PFD_MAIN_PLANE       0
-CONSTANT: PFD_OVERLAY_PLANE    1
-CONSTANT: PFD_UNDERLAY_PLANE   -1
-
 CONSTANT: LPD_TYPE_RGBA        0
 CONSTANT: LPD_TYPE_COLORINDEX  1