contentsconceptssyntaxlibrariessampleserrorsindex
Full text search
Functions: tail recursion
Prerequisite Concepts     Related Syntax  

OmniMark supports a special type of recursion called tail recursion. If calling itself or another function is the very last thing a function does, then instead of "calling" that function, OmniMark terminates the current function and "jumps" to the other function. The main effect of this is that, with a bit of care, function calls can be made that seem to be millions of levels deep without actually using up any more computer memory than a single call.

The OmniMark programmer doesn't have to do anything to make a function tail recursive. The OmniMark compiler examines each function call in a function and determines if it can be made into a tail recursive call.

The rule that a function call must be the very last thing in a function is interpreted in a very strict way. In particular, a function will not be tail recursive when:

In all of these cases something has to be done (or undone) by the calling function after returning from the called function. This cleanup prevents a "jump" to the called function.

Prerequisite Concepts
     Functions
   Functions: argument classes
   Functions: recursive
 
  Related Syntax
   define function
 
----

Top [CONTENTS] [CONCEPTS] [SYNTAX] [LIBRARIES] [SAMPLES] [ERRORS] [INDEX]

Generated: April 21, 1999 at 2:00:48 pm
If you have any comments about this section of the documentation, send email to [email protected]

Copyright © OmniMark Technologies Corporation, 1988-1999.