Elektrine lite

← Feed

@Kazinator@mstdn.ca

2026-07-03 18:29 UTC

@psf@oldbytes.space I see from the MuLISP manual that closure is a dynamic closure mechanism. But it is not a true dynamic closure mechanism. The funtion takes a list of variable symbols, and captures their current values. Then when the closure is applied, those values are temporarily installed into the dynamic scope. If the constructor were modified to take the pseudo-environment directly, you wouldn't have to do the RPLACA manipulation. A true dynamic closure captures a porton of the dynamic environment itself (not simply copying the values) and then installs it when the closure is called. I implemented such a thing 25 years ago in a dynamically scoped Lisp. Newly funcalled dynamic frames were specially marked with a "top" bit. When a lambda was evaluated, it captured a slice of the dynamic environment up to the closest frame marked as top. Lambda invocation grafted the captured frames to the top of the current dynamic environment. lambdas captured under the same environment shared the variables properly.

Replies (0)

No replies.