joshuaaaron at gmail.com
Tue May 14 16:09:59 UTC 2013
On Tue, May 14, 2013 at 11:52 AM, Taoufik Dachraoui
<dachraoui.taoufik at gmail.com> wrote:
> What is not true? I am not saying that stacks are conses; we can push and
> pop elements from a stack and macroexpanding (PUSH 1 X) gives (SETQ X (CONS
> 1 X)); so the stack, used by pop/push, in CCL is implemented
> using conses; we can implement stacks using arrays (no consing) if we wish
> Now, the reason I am asking, is that I am implementing an interpreter for a
> small language and I am using 3 stacks with a lot of consing. I wanted to
> find a solution so that I can avoid consing; I recalled when we call a
> function the passed parameters are pushed into a stack (implemented with
> registers ESP/EBP), I am wondering if I can find a way to use the
> processor's stack as for function calls to avoid consing.
> Or, how do you implement a VM using CCL for a new language? (any thing
> offered by CCL even if it is not
> standard would be acceptable).
1) Although the machine stack stores things in machine memory (the
program stack), when people talk about a program "cons'ing a lot" or
allocating lots of memory, they're almost always talking about
heap-allocated space. Even though they use the word "cons'ing", it
doesn't even have to be cons cells; it's any heap allocation (so
class objects, arrays, etc., are all included). This code doesn't
really need any heap space, so it's not consing.
2) Although the program has a stack, the program/machine stack is not
(typically (does anyone know of any exceptions?)) implemented by a
reusable abstract data structure known as a stack. The push/pop model
happens to be the same, but the program stack is just about
incrementing and decrementing the CPU's stack pointer.
Joshua Taylor, http://www.cs.rpi.edu/~tayloj/
More information about the Openmcl-devel