Re: %temp-cons
Robert Munyer <[email protected]> Sun, 26 May 2024 20:46:39 -0400
| Newsgroups | gmane.lisp.openmcl.devel |
|---|---|
| Message-ID | <[email protected]> |
> On May 21, 2024, at 1:30 PM, R. Matthew Emerson <[email protected]> wrote: > >> Does anyone know/remember what %temp-cons is? Some artifact >> from days gone past? >> >> It looks like it's currently just an alias for regular cons. >> >> There's a %temp-list, too. Garbage prevention. I believe that when a CCL developer uses any of these: %arglist %temp-cons %temp-list %temp-push make-tsp-cons ppc2-%temp-cons ppc2-%temp-list temp-cons x862-%temp-cons x862-%temp-list he or she is asserting that the cells being constructed will become unreachable garbage, before or during destruction of the current stack frame, so they can be constructed in the "temp stack" [1] instead of in the heap, so their space can be reclaimed by a mechanism that's vastly more efficient than garbage collection. There's another way to construct cells in the temp stack, but it's cumbersome. Here are two functions, equivalent except that the latter constructs a cell in the temp stack instead of in the heap: (defun foo () (length (cons t nil))) (defun bar () (let ((baz (cons t nil))) (declare (dynamic-extent baz)) (length baz))) If you evaluate "(time (foo))" and "(time (bar))", you should get a "bytes of memory allocated" line from FOO but not from BAR. Simply inserting "%temp-" would be much less cumbersome. -- Robert Munyer [1] See https://ccl.clozure.com/docs/ccl.html#stack-conventions