4 ms·
A brief skim of the document suggests: - single-reference-only for expressions (so, static object lifetime); deletion is delayed until a stack slot gets reused
by david-given 10y ago
A brief skim of the document suggests:
- single-reference-only for expressions (so, static object lifetime); deletion is delayed until a stack slot gets reused, allowing return values
- assignment to variables or values passed into functions are done by copy
- EXCEPT certain types are passed into functions by reference as an optimisation
So, basically, values are owned by either the stack or a variable. Assignment to a stack cell destroys what was there before. To keep a stacked value, it needs to be copied into a variable.
That all seems pretty intelligent, and I might steal the idea; except that I don't see any mention of how cyclic data structures or mutable data structures are implemented. Does anyone know how these are handled?
- astrobe_ 10y agoFor mutable structures you use the "context" concept, which is also used to build a form of OOP. For cyclic data structures, I'm not sure. I think one can pass a function, a list or a context to a function that expects a list. This it might do the trick.
- david-given 10y agoFrom Wikipedia: > Sharing of sub-objects among objects, cyclic structures, or multiple variables pointing to the same object are not supported in newLISP. Dang.