5 ms·
Not explicitly noted in original message was, reply to remarks were about examples of how that already exists in lisp without need to modify lisp. 'basic' loop
by sargstuff 4y ago
Not explicitly noted in original message was, reply to remarks were about examples of how that already exists in lisp without need to modify lisp.
'basic' loop in lisp is tree/heap traversal from initial outer ().
The standard loop macro just provides appropriate way/window dressing to quickly comprehend what's being done (aka while, counter loop, do while, repeat, etc).
What's refered to as generators in other languages, is implicit in how lisp traverses ().
per return a struct and not a list:
Generator approach would 'store the list of values' and return a single struct every time called until no more structs from 'original turn'.
traversal of () is the 'generic loop' in lisp. (clos or not)
set/quote discussion also left out the needed eval command.
stated 'rebinding' is already implicet in s-expressions used in lisp. request as given is an lvalue = rvalue(s) interpretation (m-expression). s-expressions are core of lisp. convertion lisp to use m-expressions instead of s-expressions would mean creating a new language.
- 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.