]> gitweb.factorcode.org Git - factor.git/commitdiff
vocabs: simplify M\ string require.
authorJohn Benediktsson <mrjbq7@gmail.com>
Fri, 10 Feb 2017 00:24:05 +0000 (16:24 -0800)
committerJohn Benediktsson <mrjbq7@gmail.com>
Fri, 10 Feb 2017 00:24:05 +0000 (16:24 -0800)
core/vocabs/vocabs.factor

index 656f040c75bf42861b7e292ae8fe1558114bec6f..be71fa0804178e8a4a71759822e120d087854d1d 100644 (file)
@@ -139,28 +139,20 @@ PREDICATE: runnable-vocab < vocab
 
 INSTANCE: vocab-spec definition-mixin
 
-: 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.
-M: string require ( vocab -- )
-    dup ".private" ?tail [
-        over lookup-vocab
-        [ 2drop ]
-        [ nip call-require-hook ]
-        if
-    ] [
-        nip call-require-hook
-    ] if ;
+! 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
+    [ ".private" ?tail ] keep swap [ lookup-vocab not ] when
+    [ require-hook get call( name -- ) ] [ drop ] if ;
 
 : load-vocab ( name -- vocab )
     [ require ] [ lookup-vocab ] bi ;