idiom <name> { entry | change | exit | local } ... <Idiom Body> return
A section of code within a Method, Function, or Sequence may be broken out into an Idiom procedure. Idioms are placed in the source file after the primary method. An Idiom may not be called from outside the method. While an Idiom can call other Idioms, they must be appear in the source file before they can be called. Idioms may not be recursively call themselves.
Any parameters and variables declared in the primary method may be referenced by an Idiom. An Idiom may also declare it's own parameters and Local variables that can not be accessed by the Primary method or other Idioms. However, the names of local Idiom parameters and its Locals may not be used elsewhere in the primary method or any other Idiom.
Global variable declarations and Use or Alter declarations are not permitted in an Idiom. However, an Idiom may access Global variables visible to the primary method. Idioms are useful in the following circumstances:
Here is an example using Idiom methods.
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: : method PRIMARY: The primary method in a source file change Q Queue..string, S Stack..string local Error = 0 Bit : :............................................................................... NEST.METHOD DO P from Q ITERATE.METHOD P, I, Hit.Me - DO P from S ITERATE.METHOD P, J, Hit.You - ITERATE.METHOD T, U, Hit.Us return :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: : catch: An exception handler goes before any idioms. :............................................................................... IF Error FIX.IT - return :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: : idiom ITERATE.METHOD: An Idiom method can be called from the primary Method. entry V string, I word exit Hit = 0 Bit : :............................................................................... IF V = form( I ) Hit = 1 - return :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: : idiom NEST.METHOD: An Idiom method can call annother Idiom above it. : :............................................................................... IF Q`Empty EMPTY S - return