Anonymous recursion: Difference between revisions

m
(Added Quackery.)
m (→‎{{header|Quackery}}: improved text)
Line 2,336:
would cause the nest <code>[ dup 1 - recurse ]</code>to be evaluated, and the program would go into a tailspin, recursively evaluating that nest until the return stack overflowed.
 
This limitation can be overcome with the understanding that recursion can be factored out into two ideas, i.e. self=-reference and evaluation. The self-reference word in Quackery is <code>this</code>, which puts a pointer to the current nest on the data stack (usually just called "the stack") and the evaluation word is <code>do</code>, which takes aan pointeritem from the stack and evaluates it. So <code>this do</code> is equivalent to <code>recurse</code>.
 
The final example fixes the previous example by puttingusing <code>this</code> and <code>do</code> to put the pointer to the current nest on the stack at the correct level of nesting and evaluatingevaluate it within the nested nests with <code>do</code>.
 
<pre>[ dup 0 < iff
1,462

edits