[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
stack consing
I would like to be able to cons (or allocate storage such as
arrays, structures, and instances) on the stack in a way
that WITH-STACK-LIST doesn't allow me to. I would like to
be able to arbitrarily cons within loops and other control
constructs which I can't do with WITH-STACK-LIST. I can
guarantee that when I leave the function doing consing,
there will be no references to the conses generated. I would
like them to be automatically reclaimed when the function
exits without the overhead of GC or resources.
For example:
(defun reverse-on-the-stack (l)
(loop with r = nil
for s = l then (rest s)
while (not (null s))
do (setf r (STACK-CONS (first s r)))
finally (return (a-function-that-uses-r-but-doesnt-retain-any-pointers-to-it r))))
As you can see, WITH-STACK-LIST is syntactically too restrictive
to accomplish the above task.
Thanks in advance for any help,
Jeff
-------