Lively Linear Lisp – 'Look Ma, No Garbage!' (1992) [pdf]
dl.acm.org
dl.acm.org
Lively Linear Lisp – 'Look Ma, No Garbage' (1992) - https://news.ycombinator.com/item?id=20369522 - July 2019 (39 comments)
Lively Linear Lisp – 'Look Ma, No Garbage' (1991) - https://news.ycombinator.com/item?id=14248419 - May 2017 (18 comments)
[edit]
I see why C without scoping would still produce garbage:
int* foo = malloc(sizeof(int));
foo = null;
Linear Lisp forces you to clean up memory. It doesn't allow complex data structures to be assigned to variables without moving the existing contents of those variables elsewhere where they can be disposed of later.[0] https://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.31...
2. You can build abstractions that call free for you. The common withX callback-style function can be better typed with linear types and call free for you, for instance.
with-some-resource { res ->
// use res as you like
}
The with-some-resource function takes care of the resource management, while the type system takes care res doesn't escape the lambda.The original situation (malloc gives you a linear variable) handles what you want. A function that takes the variable but does not return it effectively "takes ownership of it" and the type system will force a free.
There's a "Linear Constraints" paper draft out there that emulates ownership and borrowing with linear types, and uses the titular new language feature to greatly improve ergonomics.
With affine types, like Rust, you can use a type zero or one times, with linear types you must use it exactly once.
So not calling free() as per all possible dataflow analysis, would be a compilation error.
By the way, this is the approach adopted by Haskell with Linear Haskell extensions.
Also, what does the free-list register do?
The free list holds all the cons cells not in use. Note that in this machine, there is no way to create or destroy cons cells - that's the whole point! Rather, when you need to cons some values, you pull a cell off the free list and populate it (see the implementation of CONS), and when you want to throw a cons cell away, you put it back on the free list (see the implementations of POP and FREE).
CL-USER> (let ((list (list 1 2 3 4)))
(cons 5 list)
list)
(1 2 3 4)
CL-USER> (let ((list (list 1 2 3 4)))
(push 5 list )
list)
(5 1 2 3 4)