factor: more << >> to COMPILE<

locals-and-roots
Doug Coleman 2016-06-13 16:57:20 -07:00
parent f51e1a50f9
commit c047c6c10a
14 changed files with 21 additions and 21 deletions

View File

@ -45,7 +45,7 @@ HELP: load-library
HELP: add-library
{ $values { "name" string } { "path" string } { "abi" "one of " { $link cdecl } " or " { $link stdcall } } }
{ $description "Defines a new logical library named " { $snippet "name" } " located in the file system at " { $snippet "path" } " and the specified ABI. You can find the location of the library via words in " { $vocab-link "alien.libraries.finder" } ". The logical library name can then be used by a " { $link postpone\ library: } " form to specify the logical library for subsequent " { $link postpone\ FUNCTION: } " definitions." }
{ $notes "Because the entire source file is parsed before top-level forms are executed, " { $link add-library } " must be placed within a " { $snippet "<< ... >>" } " parse-time evaluation block."
{ $notes "Because the entire source file is parsed before top-level forms are executed, " { $link add-library } " must be placed within a " { $snippet "COMPILE< ... COMPILE>" } " parse-time evaluation block."
$nl
"This ensures that if the logical library is later used in the same file, for example by a " { $link postpone\ FUNCTION: } " definition. Otherwise, the " { $link add-library } " call will happen too late, after compilation, and the C function calls will not refer to the correct library."
$nl

View File

@ -23,7 +23,7 @@ $nl
ARTICLE: "compilation-units" "Compilation units"
"A " { $emphasis "compilation unit" } " scopes a group of related definitions. They are compiled and entered into the system in one atomic operation."
$nl
"When a source file is being parsed, all definitions are part of a single compilation unit, unless the " { $link postpone\ << } " parsing word is used to create nested compilation units."
"When a source file is being parsed, all definitions are part of a single compilation unit, unless the " { $link \ COMPILE< } " parsing word is used to create nested compilation units."
$nl
"Words defined in a compilation unit may not be called until the compilation unit is finished. The parser detects this case for parsing words and throws a " { $link staging-violation } ". Similarly, an attempt to use a macro from a word defined in the same compilation unit will throw a " { $link transform-expansion-error } ". Calling any other word from within its own compilation unit throws an " { $link undefined } " error."
$nl

View File

@ -54,7 +54,7 @@ observer add-definition-observer
defer: nesting-test
{ } [ "in: compiler.units.tests << : nesting-test ( -- ) ; >>" eval( -- ) ] unit-test
{ } [ "in: compiler.units.tests COMPILE< : nesting-test ( -- ) ; COMPILE>" eval( -- ) ] unit-test
observer remove-definition-observer

View File

@ -3,7 +3,7 @@ locals.parser namespaces parser prettyprint sequences sorting
tools.test vocabs vocabs.parser ;
in: locals.parser.tests
! XXX: remove the << and >> below and make test-all pass
! XXX: remove the COMPILE< and COMPILE> below and make test-all pass
COMPILE<
! (::)

View File

@ -278,7 +278,7 @@ HELP: staging-violation
{ $values { "word" word } }
{ $description "Throws a " { $link staging-violation } " error." }
{ $error-description "Thrown by the parser if a parsing word is used in the same compilation unit as where it was defined; see " { $link "compilation-units" } "." }
{ $notes "One possible workaround is to use the " { $link postpone\ << } " word to execute code at parse time. However, executing words defined in the same source file at parse time is still prohibited." } ;
{ $notes "One possible workaround is to use the " { $link \ COMPILE< } " word to execute code at parse time. However, executing words defined in the same source file at parse time is still prohibited." } ;
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." }

View File

@ -466,7 +466,7 @@ defer: foo
{ t } [ "staging-problem-test-2" "parser.tests" lookup-word >boolean ] unit-test
{ [ ] } [
"in: parser.tests << : staging-problem-test-1 ( -- a ) 1 ; >> : staging-problem-test-2 ( -- a ) staging-problem-test-1 ;"
"in: parser.tests COMPILE< : staging-problem-test-1 ( -- a ) 1 ; COMPILE> : staging-problem-test-2 ( -- a ) staging-problem-test-1 ;"
<string-reader> "staging-problem-test" parse-stream
] unit-test
@ -539,7 +539,7 @@ EXCLUDE: qualified.tests.bar => x ;
! Two similar bugs
! Replace : def with something in << COMPILE>
! Replace : def with something in COMPILE< COMPILE>
/* { [ ] } [
"in: parser.tests : was-once-a-word-bug ( -- ) ;"
<string-reader> "was-once-a-word-test" parse-stream
@ -548,7 +548,7 @@ EXCLUDE: qualified.tests.bar => x ;
{ t } [ "was-once-a-word-bug" "parser.tests" lookup-word >boolean ] unit-test
{ [ ] } [
"in: parser.tests use: words << \"was-once-a-word-bug\" \"parser.tests\" create-word [ ] ( -- ) define-declared >>"
"in: parser.tests use: words COMPILE< \"was-once-a-word-bug\" \"parser.tests\" create-word [ ] ( -- ) define-declared COMPILE>"
<string-reader> "was-once-a-word-test" parse-stream
] unit-test

View File

@ -884,7 +884,7 @@ HELP: call-next-method
{ \ call-next-method (call-next-method) next-method } related-words
{ \ << \ >> } related-words
{ \ COMPILE< \ COMPILE> } related-words
HELP: \ call(
{ $syntax "call( stack -- effect )" }

View File

@ -67,7 +67,7 @@ forget: another-forgotten
defer: deferred
[ deferred ] [ T{ undefined-word f deferred } = ] must-fail-with
[ "in: words.tests defer: not-compiled << not-compiled >>" eval( -- ) ]
[ "in: words.tests defer: not-compiled COMPILE< not-compiled COMPILE>" eval( -- ) ]
[ error>> [ undefined-word? ] [ word>> name>> "not-compiled" = ] bi and ] must-fail-with
{ } [ "in: words.tests forget: not-compiled" eval( -- ) ] unit-test
@ -85,7 +85,7 @@ defer: deferred
[ forget ] with-compilation-unit
] when*
[ "in: words.tests : undef-test ( -- ) ; << undef-test >>" eval( -- ) ]
[ "in: words.tests : undef-test ( -- ) ; COMPILE< undef-test COMPILE>" eval( -- ) ]
[ error>> undefined-word? ] must-fail-with
{ } [

View File

@ -3,7 +3,7 @@ alien.libraries.finder alien.syntax assocs classes.struct kernel sequences
system ;
in: python.ffi
! << "python" { "3.0" "3" "2.7" "2.6" } ! Python 3 has a different api, enable someday
! COMPILE< "python" { "3.0" "3" "2.7" "2.6" } ! Python 3 has a different api, enable someday
COMPILE< "python"
{ "python2.7" "python2.6" "python27" "python26" } find-library-from-list
cdecl add-library COMPILE>

View File

@ -18,7 +18,7 @@ HELP: find-library
{ $description
"Used to load libraries whose exact filenames is not known in advance:"
{ $code
"<< \"sqlite\" \"sqlite3\" find-library cdecl add-library >>"
"COMPILE< \"sqlite\" \"sqlite3\" find-library cdecl add-library COMPILE>"
}
"Note the parse time evaluation with " { $link postpone\ << } "."
"Note the parse time evaluation with " { $link \ COMPILE< } "."
} ;

View File

@ -1,10 +1,10 @@
USING: kernel tools.test definitions compiler.units ;
in: compiler.tests.redefine21
[ ] [ : a ( -- ) ; << : b ( quot -- ) call a ; inline COMPILE> [ ] b ] unit-test
[ ] [ : a ( -- ) ; COMPILE< : b ( quot -- ) call a ; inline COMPILE> [ ] b ] unit-test
[ ] [ [ { a b } forget-all ] with-compilation-unit ] unit-test
[ ] [ : A ( -- ) ; << : B ( -- ) A ; inline COMPILE> B ] unit-test
[ ] [ : A ( -- ) ; COMPILE< : B ( -- ) A ; inline COMPILE> B ] unit-test
[ ] [ [ { A B } forget-all ] with-compilation-unit ] unit-test

View File

@ -145,7 +145,7 @@ FUNCTOR;
[ [ ] ] [
"in: functors.tests
<< \"some\" redefine-test >>" <string-reader> "functors-test" parse-stream
COMPILE< \"some\" redefine-test COMPILE>" <string-reader> "functors-test" parse-stream
] unit-test
test-redefinition

View File

@ -59,7 +59,7 @@ CONSTANT: objects
B{ 50 13 55 64 1 }
?{ t f t f f t f }
double-array{ 1.0 3.0 4.0 1.0 2.35 0.33 }
<< 1 [ 2 ] curry suffix! COMPILE>
COMPILE< 1 [ 2 ] curry suffix! COMPILE>
{ { "a" "bc" } { "de" "fg" } }
H{ { "a" "bc" } { "de" "fg" } }
} ;

View File

@ -5,7 +5,7 @@ in: vocabs.prettyprint.tests
: manifest-test-1 ( -- string )
"USING: kernel namespaces vocabs.parser vocabs.prettyprint ;
<< manifest get pprint-manifest >>" ;
COMPILE< manifest get pprint-manifest COMPILE>" ;
{
"USING: kernel namespaces vocabs.parser vocabs.prettyprint ;"
@ -16,7 +16,7 @@ in: vocabs.prettyprint.tests
"USING: kernel namespaces vocabs.parser vocabs.prettyprint ;
in: vocabs.prettyprint.tests
<< manifest get pprint-manifest >>" ;
COMPILE< manifest get pprint-manifest COMPILE>" ;
{
"USING: kernel namespaces vocabs.parser vocabs.prettyprint ;
@ -32,7 +32,7 @@ in: vocabs.prettyprint.tests"
EXCLUDE: parser => run-file ;
in: vocabs.prettyprint.tests
<< manifest get pprint-manifest >>" ;
COMPILE< manifest get pprint-manifest COMPILE>" ;
{
"USING: kernel namespaces vocabs.parser vocabs.prettyprint ;