4 ms·
> basic' loop in lisp is tree/heap traversal from initial outer (). That's completely false, except that loops can be used to code a tree traversal. Looping i
by kazinator 4y ago
> basic' loop in lisp is tree/heap traversal from initial outer ().
That's completely false, except that loops can be used to code a tree traversal.
Looping is a control construct centered around a backward branch, updates to iteration variables and termination testing. Loops can compile code that has nothing to do with the heap.
- sargstuff 4y agoWhy prefer a non-functional construct over a functional construct in a functional language? The lisp loop macro simplifies the s-expression tree/heap traversal for benifit of coder/reader. The lisp loop macro is implilmented based on s-expression tree traversal. Trees are used with closures. Heaps are used with objects. (lisp & non-lisp) In lisp can debate what's an 'object', but multiple thunks are managed through a heap structure. Tree (or heap form of tree) order traversals are forms of binary backward branching. Tree traversal can be structured so 'iteration variables' are not needed. Default lisp termination is 'NIL' If only returning a single struc (with no memory management), then heap not required. If returning multiple strucs in a list/tree (aka multiple s-expressions), then the s-expression 'thunks' will be managed via heap.