change literals so that $ works with constants in same compilation unit
parent
df7806ef01
commit
ddce0e0a10
|
@ -1,19 +1,19 @@
|
|||
! Copyright (C) 2008 Joe Groff.
|
||||
! See http://factorcode.org/license.txt for BSD license.
|
||||
USING: help.markup help.syntax multiline ;
|
||||
USING: help.markup help.syntax kernel multiline ;
|
||||
IN: literals
|
||||
|
||||
HELP: $
|
||||
{ $syntax "$ word" }
|
||||
{ $description "Executes " { $snippet "word" } " at parse time and adds the result(s) to the parser accumulator." }
|
||||
{ $notes "Since " { $snippet "word" } " is executed at parse time, " { $snippet "$" } " cannot be used with words defined in the same compilation unit." }
|
||||
{ $notes { $snippet "word" } "'s definition is looked up and " { $link call } "ed at parse time, so words that reference words in the current compilation unit cannot be used with " { $snippet "$" } "." }
|
||||
{ $examples
|
||||
|
||||
{ $example <"
|
||||
USING: kernel literals prettyprint ;
|
||||
IN: scratchpad
|
||||
|
||||
<< : five 5 ; >>
|
||||
CONSTANT: five 5
|
||||
{ $ five } .
|
||||
"> "{ 5 }" }
|
||||
|
||||
|
@ -30,7 +30,7 @@ IN: scratchpad
|
|||
HELP: $[
|
||||
{ $syntax "$[ code ]" }
|
||||
{ $description "Calls " { $snippet "code" } " at parse time and adds the result(s) to the parser accumulator." }
|
||||
{ $notes "Since " { $snippet "code" } " is executed at parse time, it cannot reference any words defined in the same compilation unit." }
|
||||
{ $notes "Since " { $snippet "code" } " is " { $link call } "ed at parse time, it cannot reference any words defined in the same compilation unit." }
|
||||
{ $examples
|
||||
|
||||
{ $example <"
|
||||
|
|
|
@ -2,11 +2,12 @@ USING: kernel literals math tools.test ;
|
|||
IN: literals.tests
|
||||
|
||||
<<
|
||||
: five 5 ;
|
||||
: seven-eleven 7 11 ;
|
||||
: six-six-six 6 6 6 ;
|
||||
>>
|
||||
|
||||
: five 5 ;
|
||||
: seven-eleven 7 11 ;
|
||||
|
||||
[ { 5 } ] [ { $ five } ] unit-test
|
||||
[ { 7 11 } ] [ { $ seven-eleven } ] unit-test
|
||||
[ { 6 6 6 } ] [ { $ six-six-six } ] unit-test
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
! (c) Joe Groff, see license for details
|
||||
USING: continuations kernel parser words quotations vectors ;
|
||||
USING: accessors continuations kernel parser words quotations vectors ;
|
||||
IN: literals
|
||||
|
||||
: $ scan-word [ execute ] curry with-datastack >vector ; parsing
|
||||
: $ scan-word [ def>> call ] curry with-datastack >vector ; parsing
|
||||
: $[ \ ] parse-until >quotation with-datastack >vector ; parsing
|
||||
|
|
Loading…
Reference in New Issue