Minor doc improvements
parent
2e119a0ae7
commit
ab45402d04
|
@ -275,7 +275,7 @@ $nl
|
|||
"The simplest combinators do not take an effect declaration. The compiler checks the stack effect at compile time, rejecting the program if this cannot be done:"
|
||||
{ $subsection call }
|
||||
{ $subsection execute }
|
||||
"The second set of combinators takes an effect declaration. The stack effect of the quotation or word is checked at runtime:"
|
||||
"The second set of combinators takes an effect declaration. Note that the opening parenthesis is actually part of the word name; these are parsing words, and they read a stack effect until the corresponding closing parenthesis. The stack effect of the quotation or word is then checked at runtime:"
|
||||
{ $subsection POSTPONE: call( }
|
||||
{ $subsection POSTPONE: execute( }
|
||||
"The above are syntax sugar. The underlying words are a bit more verbose but allow non-constant effects to be passed in:"
|
||||
|
@ -303,11 +303,25 @@ ABOUT: "combinators"
|
|||
|
||||
HELP: call-effect
|
||||
{ $values { "quot" quotation } { "effect" effect } }
|
||||
{ $description "Given a quotation and a stack effect, calls the quotation, asserting at runtime that it has the given stack effect. This is a macro which expands given a literal effect parameter, and an arbitrary quotation which is not required at compile time." } ;
|
||||
{ $description "Given a quotation and a stack effect, calls the quotation, asserting at runtime that it has the given stack effect. This is a macro which expands given a literal effect parameter, and an arbitrary quotation which is not required at compile time." }
|
||||
{ $examples
|
||||
"The following two lines are equivalent:"
|
||||
{ $code
|
||||
"call( a b -- c )"
|
||||
"(( a b -- c )) call-effect"
|
||||
}
|
||||
} ;
|
||||
|
||||
HELP: execute-effect
|
||||
{ $values { "word" word } { "effect" effect } }
|
||||
{ $description "Given a word and a stack effect, executes the word, asserting at runtime that it has the given stack effect. This is a macro which expands given a literal effect parameter, and an arbitrary word which is not required at compile time." } ;
|
||||
{ $description "Given a word and a stack effect, executes the word, asserting at runtime that it has the given stack effect. This is a macro which expands given a literal effect parameter, and an arbitrary word which is not required at compile time." }
|
||||
{ $examples
|
||||
"The following two lines are equivalent:"
|
||||
{ $code
|
||||
"execute( a b -- c )"
|
||||
"(( a b -- c )) execute-effect"
|
||||
}
|
||||
} ;
|
||||
|
||||
HELP: execute-effect-unsafe
|
||||
{ $values { "word" word } { "effect" effect } }
|
||||
|
|
|
@ -834,6 +834,14 @@ HELP: call(
|
|||
|
||||
HELP: execute(
|
||||
{ $syntax "execute( stack -- effect )" }
|
||||
{ $description "Calls the word on the top of the stack, asserting that it has the given stack effect. The word does not need to be known at compile time." } ;
|
||||
{ $description "Calls the word on the top of the stack, asserting that it has the given stack effect. The word does not need to be known at compile time." }
|
||||
{ $examples
|
||||
{ $code
|
||||
"IN: scratchpad"
|
||||
""
|
||||
": eat ( -- ) ; : sleep ( -- ) ; : hack ( -- ) ;"
|
||||
"{ eat sleep hack } [ execute( -- ) ] each"
|
||||
}
|
||||
} ;
|
||||
|
||||
{ POSTPONE: call( POSTPONE: execute( } related-words
|
||||
|
|
Loading…
Reference in New Issue