|
|
|
< recursion |
Routines |
variables > |
|
|
Routines are a rarely used, but nevertheless powerful feature of Tymless. Like functions they contain program code that can be called repeatedly, but unlike functions they behave like complete Tymless programs in their own right. They can have functions of their own, and have their own recursion-handling machinery. Perhaps their main purpose is to allow a recursively drawn shape or pattern to be used as the initiator of another recursive pattern. Sound complicated? Well yes. I said they were rarely used! Here is an example: The routine is declared using two colons :: to differentiate it from a mere function. A routine call is exactly the same as a function call, except that a routine cannot be called after the point at which it is declared. This restriction means that routines cannot be called recursively. You can pass parameters to a routine. All functions declared after the routine declaration 'belong' to that routine (at least until any further routunes are declared). These functions cannot be called from outside the routine, but they can call each other recursively. Routines have their own recursion limit and recursion depth counter, so $l can be set to some new value without affecting recursion handling in the main routine. A routine is processed by its own child-turtle,
and can therefore read all the variables
in existence when it was called, but any changes it makes are ignored
when it ends. A routine can also read and alter all public
variables and read all constants. |
|
< recursion |
variables > |