[ ] [ "vocabs.loader.test.m" require ] unit-test
[ t ] [ "vocabs.loader.test.n" lookup-vocab >boolean ] unit-test
+[ ] [ "vocabs.loader.test.p.private" require ] unit-test
+[ { "foo" } ] [ "vocabs.loader.test.p" words [ name>> ] map ] unit-test
+
[
- "mno" [ "vocabs.loader.test." swap suffix forget-vocab ] each
+ "mnop" [ "vocabs.loader.test." swap suffix forget-vocab ] each
] with-compilation-unit
dup vocab-name blacklist get at* [ rethrow ] [
drop dup find-vocab-root
[ (load-vocab) ] [ dup lookup-vocab [ ] [ no-vocab ] ?if ] if
- ] if
-] load-vocab-hook set-global
+ ] if drop
+] require-hook set-global
M: vocab-spec where vocab-source-path dup [ 1 2array ] when ;
{ $description "Removes a vocabulary. All words in the vocabulary are forgotten." }
{ $notes "This word must be called from inside " { $link with-compilation-unit } "." } ;
-HELP: load-vocab-hook
-{ $var-description { $quotation "( name -- vocab )" } " which loads a vocabulary. This quotation is called by " { $link load-vocab } ". The default value should not need to be changed; this functionality is implemented via a hook stored in a variable to break a circular dependency which would otherwise exist from " { $vocab-link "vocabs" } " to " { $vocab-link "vocabs.loader" } " to " { $vocab-link "parser" } " back to " { $vocab-link "vocabs" } "." } ;
+HELP: require-hook
+{ $var-description { $quotation "( name -- )" } " which loads a vocabulary. This quotation is called by " { $link require } ". The default value should not need to be changed; this functionality is implemented via a hook stored in a variable to break a circular dependency which would otherwise exist from " { $vocab-link "vocabs" } " to " { $vocab-link "vocabs.loader" } " to " { $vocab-link "parser" } " back to " { $vocab-link "vocabs" } "." } ;
HELP: words-named
{ $values { "str" string } { "seq" "a sequence of words" } }
M: vocab-spec forget* forget-vocab ;
-SYMBOL: load-vocab-hook ! ( name -- vocab )
+SYMBOL: require-hook
PREDICATE: runnable-vocab < vocab
vocab-main >boolean ;
INSTANCE: vocab-spec definition
-: call-load-vocab-hook ( name -- )
- load-vocab-hook get call( name -- vocab ) drop ;
+: call-require-hook ( name -- )
+ require-hook get call( name -- ) ;
GENERIC: require ( object -- )
M: vocab require name>> require ;
+M: vocab-link require name>> require ;
-! When calling "foo.private" require, load "foo" instead,
-! but only when "foo.private" does not exist.
-! The reason for this is that stage1 bootstrap starts out with some .private
-! vocabs that contain primitives, and loading the public vocabs would cause
-! circularity issues.
+! When calling "foo.private" require, load "foo" instead, ! but only when
+! "foo.private" does not exist. The reason for this is that stage1 bootstrap
+! starts out with some .private vocabs that contain primitives, and
+! loading the public vocabs would cause circularity issues.
M: string require ( vocab -- )
dup ".private" ?tail [
- over lookup-vocab [
- 2drop
- ] [
- nip call-load-vocab-hook
- ] if
+ over lookup-vocab
+ [ 2drop ]
+ [ nip call-require-hook ]
+ if
] [
- nip call-load-vocab-hook
+ nip call-require-hook
] if ;
: load-vocab ( name -- vocab )