Liste des Groupes | Revenir à cl forth |
dxf <dxforth@gmail.com> wrote:
Great. While I've seen co-routines mentioned, examples were rare so I
tended to ignore it.
>
-- A closed paren defined as an immediate co-routine can be used at
-- compile time to divide a word into two parts.
-- At run-time the word's first part executes then performs co-routine
-- and somewhere down the input ')' performs co-routine to return control
-- back to the the word's second part.
-- : foo( first part ) second part ;
-- Example:
: foo( ." --> " s0 @ sp! ) begin depth while 5 * . repeat ; OK
foo( 3 2 1 ) --> 5 10 15 OK
I use 'hi( foo bar baz )' to highlight the output of a sequence of
Forth words.
Les messages affichés proviennent d'usenet.