carp-lang / Carp

A statically typed lisp, without a GC, for real-time applications.
Apache License 2.0
5.52k stars 174 forks source link

Make lambdas stack allocated by default #974

Open eriksvedang opened 3 years ago

eriksvedang commented 3 years ago

The lambda envs could be created on the stack and only moved to the heap if the lambda is copied.

The type of a lambda literal would change to a ref to a function (which would make them immediately suitable to pass as function arguments in most cases.)

TimDeve commented 3 years ago

Love that, on my current project I have a few allocations in the critical path because closures were easier to use than the alternative. This proposal would remove them.

scolsen commented 3 years ago

Sounds wonderful!