diff --git a/basis/bit-sets/bit-sets-tests.factor b/basis/bit-sets/bit-sets-tests.factor index 4e97e703d0..0d4543f8f2 100644 --- a/basis/bit-sets/bit-sets-tests.factor +++ b/basis/bit-sets/bit-sets-tests.factor @@ -11,6 +11,9 @@ IN: bit-sets.tests T{ bit-set f ?{ f f t f t f } } intersect ] unit-test +[ f ] [ T{ bit-set f ?{ t f f f t f } } null? ] unit-test +[ t ] [ T{ bit-set f ?{ f f f f f f } } null? ] unit-test + [ T{ bit-set f ?{ t f t f f f } } ] [ T{ bit-set f ?{ t t t f f f } } T{ bit-set f ?{ f t f f t t } } diff diff --git a/basis/bootstrap/compiler/compiler.factor b/basis/bootstrap/compiler/compiler.factor index 9cb9c125ab..56109e2de6 100644 --- a/basis/bootstrap/compiler/compiler.factor +++ b/basis/bootstrap/compiler/compiler.factor @@ -20,8 +20,8 @@ IN: bootstrap.compiler "alien.remote-control" require ] unless -"prettyprint" "alien.prettyprint" require-when -"debugger" "alien.debugger" require-when +{ "boostrap.compiler" "prettyprint" } "alien.prettyprint" require-when +{ "boostrap.compiler" "debugger" } "alien.debugger" require-when "cpu." cpu name>> append require diff --git a/basis/bootstrap/handbook/handbook.factor b/basis/bootstrap/handbook/handbook.factor index 11f7349b79..ef7a456b7b 100644 --- a/basis/bootstrap/handbook/handbook.factor +++ b/basis/bootstrap/handbook/handbook.factor @@ -1,4 +1,4 @@ USING: vocabs.loader vocabs kernel ; IN: bootstrap.handbook -"bootstrap.help" "help.handbook" require-when +{ "boostrap.handbook" "bootstrap.help" } "help.handbook" require-when diff --git a/basis/bootstrap/threads/threads.factor b/basis/bootstrap/threads/threads.factor index 3a8fe98cf4..2bc8d612b6 100644 --- a/basis/bootstrap/threads/threads.factor +++ b/basis/bootstrap/threads/threads.factor @@ -4,6 +4,6 @@ USING: vocabs.loader kernel io.thread threads compiler.utilities namespaces ; IN: bootstrap.threads -"debugger" "debugger.threads" require-when +{ "bootstrap.threads" "debugger" } "debugger.threads" require-when [ yield ] yield-hook set-global diff --git a/basis/bootstrap/ui/tools/tools.factor b/basis/bootstrap/ui/tools/tools.factor index 7db69ce9c1..3efd156983 100644 --- a/basis/bootstrap/ui/tools/tools.factor +++ b/basis/bootstrap/ui/tools/tools.factor @@ -4,7 +4,7 @@ USING: kernel vocabs vocabs.loader sequences system ; [ "bootstrap." prepend vocab ] all? [ "ui.tools" require - "ui.backend.cocoa" "ui.backend.cocoa.tools" require-when + { "ui.backend.cocoa" } "ui.backend.cocoa.tools" require-when "ui.tools.walker" require ] when diff --git a/basis/classes/struct/struct.factor b/basis/classes/struct/struct.factor index ffde233748..605ee573f5 100644 --- a/basis/classes/struct/struct.factor +++ b/basis/classes/struct/struct.factor @@ -404,4 +404,4 @@ FUNCTOR-SYNTAX: STRUCT: USING: vocabs vocabs.loader ; -"prettyprint" "classes.struct.prettyprint" require-when +{ "classes.struct" "prettyprint" } "classes.struct.prettyprint" require-when diff --git a/basis/http/client/client.factor b/basis/http/client/client.factor index 1221ee39f3..aa2fc8962b 100644 --- a/basis/http/client/client.factor +++ b/basis/http/client/client.factor @@ -194,6 +194,6 @@ ERROR: download-failed response ; : http-delete ( url -- response data ) http-request ; -USING: vocabs vocabs.loader ; +USE: vocabs.loader -"debugger" "http.client.debugger" require-when +{ "http.client" "debugger" } "http.client.debugger" require-when diff --git a/basis/locals/locals.factor b/basis/locals/locals.factor index 7d67881c47..5fd12e2fb3 100644 --- a/basis/locals/locals.factor +++ b/basis/locals/locals.factor @@ -26,5 +26,5 @@ SYNTAX: MEMO:: (::) define-memoized ; "locals.fry" } [ require ] each -"prettyprint" "locals.definitions" require-when -"prettyprint" "locals.prettyprint" require-when +{ "locals" "prettyprint" } "locals.definitions" require-when +{ "locals" "prettyprint" } "locals.prettyprint" require-when diff --git a/basis/math/rectangles/rectangles.factor b/basis/math/rectangles/rectangles.factor index 78ac5457bc..15f4d5376d 100644 --- a/basis/math/rectangles/rectangles.factor +++ b/basis/math/rectangles/rectangles.factor @@ -64,4 +64,4 @@ M: rect contains-point? USE: vocabs.loader -"prettyprint" "math.rectangles.prettyprint" require-when +{ "math.rectangles" "prettyprint" } "math.rectangles.prettyprint" require-when diff --git a/basis/math/vectors/simd/simd.factor b/basis/math/vectors/simd/simd.factor index 65d6e113bf..c845a4df63 100644 --- a/basis/math/vectors/simd/simd.factor +++ b/basis/math/vectors/simd/simd.factor @@ -339,4 +339,4 @@ M: short-8 v*hs+ M: int-4 v*hs+ int-4-rep [ (simd-v*hs+) ] [ call-next-method ] vv->v-op longlong-2-cast ; inline -"mirrors" "math.vectors.simd.mirrors" require-when +{ "math.vectors.simd" "mirrors" } "math.vectors.simd.mirrors" require-when diff --git a/basis/peg/peg.factor b/basis/peg/peg.factor index ca7d28bb97..e50c1d8d95 100644 --- a/basis/peg/peg.factor +++ b/basis/peg/peg.factor @@ -628,6 +628,6 @@ SYNTAX: PEG: ] append! ] ; -USING: vocabs vocabs.loader ; +USE: vocabs.loader -"debugger" "peg.debugger" require-when +{ "debugger" "peg" } "peg.debugger" require-when diff --git a/basis/regexp/regexp.factor b/basis/regexp/regexp.factor index eea0a26ea5..bbfe440967 100644 --- a/basis/regexp/regexp.factor +++ b/basis/regexp/regexp.factor @@ -216,6 +216,6 @@ SYNTAX: R` CHAR: ` parsing-regexp ; SYNTAX: R{ CHAR: } parsing-regexp ; SYNTAX: R| CHAR: | parsing-regexp ; -USING: vocabs vocabs.loader ; +USE: vocabs.loader -"prettyprint" "regexp.prettyprint" require-when +{ "prettyprint" "regexp" } "regexp.prettyprint" require-when diff --git a/basis/specialized-arrays/specialized-arrays.factor b/basis/specialized-arrays/specialized-arrays.factor index c82ebd78c8..38f97303ba 100644 --- a/basis/specialized-arrays/specialized-arrays.factor +++ b/basis/specialized-arrays/specialized-arrays.factor @@ -173,6 +173,6 @@ SYNTAX: SPECIALIZED-ARRAYS: SYNTAX: SPECIALIZED-ARRAY: scan-c-type define-array-vocab use-vocab ; -"prettyprint" "specialized-arrays.prettyprint" require-when +{ "specialized-arrays" "prettyprint" } "specialized-arrays.prettyprint" require-when -"mirrors" "specialized-arrays.mirrors" require-when +{ "specialized-arrays" "mirrors" } "specialized-arrays.mirrors" require-when diff --git a/basis/stack-checker/errors/errors.factor b/basis/stack-checker/errors/errors.factor index 5eca37ffbe..f3aeb7bb64 100644 --- a/basis/stack-checker/errors/errors.factor +++ b/basis/stack-checker/errors/errors.factor @@ -35,4 +35,4 @@ ERROR: bad-declaration-error < inference-error declaration ; ERROR: unbalanced-branches-error < inference-error word quots declareds actuals ; -"debugger" "stack-checker.errors.prettyprint" require-when +{ "stack-checker.errors" "debugger" } "stack-checker.errors.prettyprint" require-when diff --git a/basis/typed/typed.factor b/basis/typed/typed.factor index df46303b79..65b21fcc38 100644 --- a/basis/typed/typed.factor +++ b/basis/typed/typed.factor @@ -164,6 +164,6 @@ SYNTAX: TYPED: SYNTAX: TYPED:: (::) define-typed ; -USING: vocabs vocabs.loader ; +USE: vocabs.loader -"prettyprint" "typed.prettyprint" require-when +{ "typed" "prettyprint" } "typed.prettyprint" require-when diff --git a/basis/ui/gadgets/gadgets.factor b/basis/ui/gadgets/gadgets.factor index dca340cd3b..3c1ece1f5e 100644 --- a/basis/ui/gadgets/gadgets.factor +++ b/basis/ui/gadgets/gadgets.factor @@ -395,4 +395,4 @@ M: f request-focus-on 2drop ; USE: vocabs.loader -"prettyprint" "ui.gadgets.prettyprint" require-when +{ "ui.gadgets" "prettyprint" } "ui.gadgets.prettyprint" require-when diff --git a/basis/unix/unix.factor b/basis/unix/unix.factor index dbbfbcce6e..d860bf490e 100644 --- a/basis/unix/unix.factor +++ b/basis/unix/unix.factor @@ -72,6 +72,6 @@ M: unix open-file [ open ] unix-system-call ; << -"debugger" "unix.debugger" require-when +{ "unix" "debugger" } "unix.debugger" require-when >> diff --git a/basis/urls/urls.factor b/basis/urls/urls.factor index cd470a451a..0f89ba0d9f 100644 --- a/basis/urls/urls.factor +++ b/basis/urls/urls.factor @@ -185,4 +185,4 @@ SYNTAX: URL" lexer get skip-blank parse-string >url suffix! ; USE: vocabs.loader -"prettyprint" "urls.prettyprint" require-when +{ "urls" "prettyprint" } "urls.prettyprint" require-when diff --git a/basis/windows/com/syntax/syntax.factor b/basis/windows/com/syntax/syntax.factor index 9d74ac49f8..dc6a0604fb 100644 --- a/basis/windows/com/syntax/syntax.factor +++ b/basis/windows/com/syntax/syntax.factor @@ -96,4 +96,4 @@ SYNTAX: GUID: scan string>guid suffix! ; USE: vocabs.loader -"prettyprint" "windows.com.prettyprint" require-when +{ "windows.com" "prettyprint" } "windows.com.prettyprint" require-when diff --git a/basis/x11/x11.factor b/basis/x11/x11.factor index e91c6a6909..67c94c88ea 100644 --- a/basis/x11/x11.factor +++ b/basis/x11/x11.factor @@ -33,4 +33,4 @@ SYMBOL: root : with-x ( display-string quot -- ) [ init-x ] dip [ close-x ] [ ] cleanup ; inline -"io.backend.unix" "x11.io.unix" require-when +{ "x11" "io.backend.unix" } "x11.io.unix" require-when diff --git a/basis/xml/syntax/syntax.factor b/basis/xml/syntax/syntax.factor index a58526faa3..e7e8714b29 100644 --- a/basis/xml/syntax/syntax.factor +++ b/basis/xml/syntax/syntax.factor @@ -177,4 +177,4 @@ SYNTAX: [XML USE: vocabs.loader -"inverse" "xml.syntax.inverse" require-when +{ "xml.syntax" "inverse" } "xml.syntax.inverse" require-when diff --git a/core/hash-sets/hash-sets-tests.factor b/core/hash-sets/hash-sets-tests.factor index 5b7ffafc8b..ca995a38e6 100644 --- a/core/hash-sets/hash-sets-tests.factor +++ b/core/hash-sets/hash-sets-tests.factor @@ -31,3 +31,6 @@ IN: hash-sets.tests [ f ] [ HS{ 1 2 3 } HS{ 2 3 } set= ] unit-test [ HS{ 1 2 } HS{ 1 2 3 } ] [ HS{ 1 2 } clone dup clone [ 3 swap adjoin ] keep ] unit-test + +[ t ] [ HS{ } null? ] unit-test +[ f ] [ HS{ 1 } null? ] unit-test diff --git a/core/hash-sets/hash-sets.factor b/core/hash-sets/hash-sets.factor index 3ca2cce93c..ac198a2ca2 100644 --- a/core/hash-sets/hash-sets.factor +++ b/core/hash-sets/hash-sets.factor @@ -18,6 +18,7 @@ M: hash-set delete table>> delete-at ; inline M: hash-set members table>> keys ; inline M: hash-set set-like drop dup hash-set? [ members ] unless ; M: hash-set clone table>> clone hash-set boa ; +M: hash-set null? table>> assoc-empty? ; M: sequence fast-set ; M: f fast-set drop H{ } clone hash-set boa ; diff --git a/core/sets/sets-docs.factor b/core/sets/sets-docs.factor index 5bde8a1feb..5ae9641734 100644 --- a/core/sets/sets-docs.factor +++ b/core/sets/sets-docs.factor @@ -23,6 +23,8 @@ ARTICLE: "set-operations" "Operations on sets" adjoin delete } +"To test if a set is the empty set:" +{ $subsections null? } "Basic mathematical operations, which any type of set may override for efficiency:" { $subsections diff @@ -178,3 +180,7 @@ HELP: within HELP: without { $values { "seq" sequence } { "set" set } { "subseq" sequence } } { $description "Returns the subsequence of the given sequence consisting of things that are not members of the set. This may contain duplicates, if the sequence has duplicates." } ; + +HELP: null? +{ $values { "set" set } { "?" "a boolean" } } +{ $description "Tests whether the given set is empty. This outputs " { $snippet "t" } " when given a null set of any type." } ; diff --git a/core/sets/sets-tests.factor b/core/sets/sets-tests.factor index e4bc762512..9a48acc4cf 100644 --- a/core/sets/sets-tests.factor +++ b/core/sets/sets-tests.factor @@ -61,3 +61,6 @@ IN: sets.tests [ f ] [ HS{ 1 2 3 1 2 1 } duplicates ] unit-test [ H{ { 3 HS{ 1 2 } } } ] [ H{ } clone 1 3 pick adjoin-at 2 3 pick adjoin-at ] unit-test + +[ t ] [ f null? ] unit-test +[ f ] [ { 4 } null? ] unit-test diff --git a/core/sets/sets.factor b/core/sets/sets.factor index d279f036d4..9c1870aa2e 100644 --- a/core/sets/sets.factor +++ b/core/sets/sets.factor @@ -21,10 +21,13 @@ GENERIC: subset? ( set1 set2 -- ? ) GENERIC: set= ( set1 set2 -- ? ) GENERIC: duplicates ( set -- seq ) GENERIC: all-unique? ( set -- ? ) +GENERIC: null? ( set -- ? ) ! Defaults for some methods. ! Override them for efficiency +M: set null? members null? ; inline + M: set set-like drop ; inline M: set union @@ -91,6 +94,9 @@ M: sequence set-like M: sequence members [ pruned ] keep like ; + +M: sequence null? + empty? ; inline : combine ( sets -- set ) [ f ] diff --git a/core/vocabs/loader/loader-docs.factor b/core/vocabs/loader/loader-docs.factor index d5a6be5335..423abbc277 100755 --- a/core/vocabs/loader/loader-docs.factor +++ b/core/vocabs/loader/loader-docs.factor @@ -114,10 +114,10 @@ HELP: require { $notes "To unconditionally reload a vocabulary, use " { $link reload } ". To reload changed source files only, use the words in " { $link "vocabs.refresh" } "." } ; HELP: require-when -{ $values { "if" "a vocabulary specifier" } { "then" "a vocabulary specifier" } } -{ $description "Loads the " { $snippet "then" } " vocabulary if it is not loaded and the " { $snippet "if" } " vocabulary is. If the " { $snippet "if" } " vocabulary is not loaded now, but it is later, then the " { $snippet "then" } " vocabulary will be loaded along with it at that time." } -{ $notes "This is used to express a joint dependency of vocabularies. If vocabularies " { $snippet "a" } " and " { $snippet "b" } " use code in vocabulary " { $snippet "c" } " to interact, then the following line can be placed in " { $snippet "a" } " in order express the dependency." -{ $code "\"b\" \"c\" require-when" } } ; +{ $values { "if" "a sequence of vocabulary specifiers" } { "then" "a vocabulary specifier" } } +{ $description "Loads the " { $snippet "then" } " vocabulary if it is not loaded and all of the " { $snippet "if" } " vocabulary is. If some of the " { $snippet "if" } " vocabularies are not loaded now, but they are later, then the " { $snippet "then" } " vocabulary will be loaded along with the final one." } +{ $notes "This is used to express a joint dependency of vocabularies. If vocabularies " { $snippet "a" } " and " { $snippet "b" } " use code in vocabulary " { $snippet "c" } " to interact, then the following line, which can be placed in " { $snippet "a" } " or " { $snippet "b" } ", expresses the dependency." +{ $code "{ \"a\" \"b\" } \"c\" require-when" } } ; HELP: run { $values { "vocab" "a vocabulary specifier" } } diff --git a/core/vocabs/loader/loader.factor b/core/vocabs/loader/loader.factor index 59fe06e6fd..2945736f3c 100644 --- a/core/vocabs/loader/loader.factor +++ b/core/vocabs/loader/loader.factor @@ -66,10 +66,19 @@ DEFER: require >source-loaded? ] dip [ % ] [ call( -- ) ] if-bootstrapping +done+ >>source-loaded? - vocab-name load-conditional-requires + load-conditional-requires ] [ ] [ f >>source-loaded? ] cleanup ; : load-docs ( vocab -- ) @@ -97,10 +106,12 @@ PRIVATE> load-vocab drop ; : require-when ( if then -- ) - over vocab - [ nip require ] - [ swap conditional-requires get [ swap suffix ] change-at ] - if ; + over [ vocab ] all? [ + require drop + ] [ + [ drop [ require-when-vocabs get adjoin ] each ] + [ 2array require-when-table get push ] 2bi + ] if ; : reload ( name -- ) dup vocab diff --git a/core/vocabs/loader/test/m/m.factor b/core/vocabs/loader/test/m/m.factor index d6d3bd8a7a..cd35d83e4f 100644 --- a/core/vocabs/loader/test/m/m.factor +++ b/core/vocabs/loader/test/m/m.factor @@ -1,4 +1,5 @@ USE: vocabs.loader IN: vocabs.loader.test.m -"vocabs.loader.test.o" "vocabs.loader.test.n" require-when +{ "vocabs.loader.test.o" "vocabs.loader.test.m" } +"vocabs.loader.test.n" require-when diff --git a/core/vocabs/vocabs.factor b/core/vocabs/vocabs.factor index e48d6c3031..38881673e9 100644 --- a/core/vocabs/vocabs.factor +++ b/core/vocabs/vocabs.factor @@ -1,7 +1,7 @@ ! Copyright (C) 2007, 2009 Eduardo Cavazos, Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. USING: accessors assocs strings kernel sorting namespaces -sequences definitions sets ; +sequences definitions sets combinators ; IN: vocabs SYMBOL: dictionary @@ -83,9 +83,6 @@ ERROR: bad-vocab-name name ; : check-vocab-name ( name -- name ) dup string? [ bad-vocab-name ] unless ; -SYMBOL: conditional-requires -conditional-requires [ H{ } clone ] initialize - : create-vocab ( name -- vocab ) check-vocab-name dictionary get [ ] cache diff --git a/extra/game/loop/loop.factor b/extra/game/loop/loop.factor index ffe5acd879..312d7dbd1c 100644 --- a/extra/game/loop/loop.factor +++ b/extra/game/loop/loop.factor @@ -112,6 +112,6 @@ PRIVATE> M: game-loop dispose stop-loop ; -USING: vocabs vocabs.loader ; +USE: vocabs.loader -"prettyprint" "game.loop.prettyprint" require-when +{ "game.loop" "prettyprint" } "game.loop.prettyprint" require-when diff --git a/extra/gpu/shaders/shaders.factor b/extra/gpu/shaders/shaders.factor index 974f2f8070..8a2931e431 100755 --- a/extra/gpu/shaders/shaders.factor +++ b/extra/gpu/shaders/shaders.factor @@ -632,4 +632,4 @@ M: program-instance dispose [ world>> ] [ program>> instances>> ] [ ] tri ?delete-at reset-memos ; -"prettyprint" "gpu.shaders.prettyprint" require-when +{ "gpu.shaders" "prettyprint" } "gpu.shaders.prettyprint" require-when