News for hackers. Stuff that matters.
Re:Carp – A statically typed Lisp, without a GC, for real-ti... by vnorilo on Friday October 15, 2021 @05:58AM (#28876071)
Lisp is not necessarily functional. There's a lot of mutation in Common Lisp even if the community favors a functional style.

I think the question is: how does Lisp function without garbage collecting cons cells?

For one, I'm not sure they even rely on cons cells like "real" Lisp. Clojure doesn't either. They cite ML as inspiration.

Carp language guide states object lifetimes are statically inferred [1] which my guess is they allocate on stack (or malloc/free by scope) and detect use-after-free at compile time.

Another, more theoretical approach is using linear types which require all values to be "consumed" [2]

1: https://github.com/carp-lang/Carp/blob/master/docs/LanguageG...

2: https://www.cs.utexas.edu/users/hunt/research/hash-cons/hash...

Re:Carp – A statically typed Lisp, without a GC, for real-ti... by protomikron on Friday October 15, 2021 @06:07AM (#28876112)
Thanks for the links. There's also this Reddit discussion [0] from 2 years ago (it mentions Carp btw.) and an explanation about how Carp manages memory [1].

[0] https://www.reddit.com/r/haskell/comments/d5d13i/is_it_possi...

[1] https://github.com/carp-lang/Carp/blob/master/docs/Memory.md

Re:Carp – A statically typed Lisp, without a GC, for real-ti... by alexisread on Friday October 15, 2021 @08:07AM (#28876853)
In particular, the reddit discussion mentions ASAP, which is a set of static analysis algorithms that can work with mutability, generics (polymorphism) and linear types. http://www.cl.cam.ac.uk/techreports/UCAM-CL-TR-908.pdf

As far as I'm aware, this really only applies to single threaded systems. However, if you implement threadsafe modules and keep the shared stuff internal (use the ASAP algos here), you can fit the majority of use-cases including hard-realtime constraints.

Composita is the module system I'm referring to. http://www.composita.net/Composita.html It allows concurrency with managed memory and no GC, through static analysis of the module (component) interface queues.

Re:Carp – A statically typed Lisp, without a GC, for real-ti... by timdeve on Friday October 15, 2021 @06:20AM (#28876186)
You're correct, somewhat like clojure's Vector, the default collection at runtime in Carp is an Array which is heap allocated C array with an attached length. At compile time however the dynamic language uses more standard lispy lists.