| www.delorie.com/gnu/docs/gforth/gforth_94.html | search |
![]() Buy GNU books! | |
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
A definition can be called simply be writing the name of the definition
to be called. Normally a definition is invisible during its own
definition. If you want to write a directly recursive definition, you
can use recursive to make the current definition visible, or
recurse to call the current definition directly.
doc-recursive doc-recurse
Programming style note: I prefer usingrecursivetorecurse, because calling the definition by name is more descriptive (if the name is well-chosen) than the somewhat crypticrecurse. E.g., in a quicksort implementation, it is much better to read (and think) "now sort the partitions" than to read "now do a recursive call".
For mutual recursion, use Deferred words, like this:
Defer foo : bar ( ... -- ... ) ... foo ... ; :noname ( ... -- ... ) ... bar ... ; IS foo |
Deferred words are discussed in more detail in 5.9.9 Deferred words.
The current definition returns control to the calling definition when
the end of the definition is reached or EXIT is encountered.
doc-exit doc-;s
| webmaster donations bookstore | delorie software privacy |
| Copyright © 2003 by The Free Software Foundation | Updated Jun 2003 |