On Sun, Jun 30, 2019 at 9:57 AM Peter Bex <pe...@more-magic.net> wrote:

Captured simply means that it needs to be wrapped up in the closure,
> AFAIK.  But if it's replaced, then the original variable will need
> to end up in the closure.  The only case where you can't replace is
> if either variable is assigned to, because then they don't point to
> the same thing anymore.
>

Obviously this is not something you can do in a patch,
but at some point Chicken may want to go
over to the assignment conversion strategy, in which all mutable
local variables are transformed into immutable references to boxes.

When the original code uses such a variable, it becomes a
call on box-ref, and a set! of such a variable becomes a call
on box-set!  Eventually the box will be reclaimed by the
garbage collector.  Local mutable variables are rare enough
that this does not create significant memory pressure.

Chez and perhaps other compilers use this transformation because
of how much it simplifies bookkeeping.  In ML, it's actually exposed
to the programmer, and the *only* mutable thing are boxes ("refs")
and mutable arrays.  But of course ML is not Scheme.


John Cowan          http://vrici.lojban.org/~cowan        co...@ccil.org
The experiences of the past show that there has always been a discrepancy
between plans and performance.        --Emperor Hirohito, August 1945
_______________________________________________
Chicken-hackers mailing list
Chicken-hackers@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-hackers

Reply via email to