<div dir="ltr">I did the following test with (fac 100) and (ack 3 12) and (ack 3 13) ;; ack is the ackermann function<div><br></div><div><div>CL-USER> (time (fac 100))<br></div><div>(FAC 100)</div><div>took 0 milliseconds (0.000 seconds) to run.</div>
<div>During that period, and with 1 available CPU core,</div><div> 0 milliseconds (0.000 seconds) were spent in user mode</div><div> 0 milliseconds (0.000 seconds) were spent in system mode</div><div> 3,864 bytes of memory allocated.</div>
<div>93326215443944152681699238856266700490715968264381621468592963895217599993229915608941463976156518286253697920827223758251185210916864000000000000000000000000</div></div><div><br></div><div><div>CL-USER> (time (ack 3 12))</div>
<div>(ACK 3 12)</div><div>took 3,325 milliseconds (3.325 seconds) to run.</div><div>During that period, and with 1 available CPU core,</div><div> 3,360 milliseconds (3.360 seconds) were spent in user mode</div><div> 0 milliseconds (0.000 seconds) were spent in system mode</div>
<div>32765</div></div><div><br></div><div>(ack 3 13) fails with stack overflow, this I do not understand; (ack 3 12) did not show any use of memory allocation </div><div>and (ack 3 13) fails for stack overflow?</div><div>
<br></div><div>Taoufik</div><div><br></div><div><br></div><div><br></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Tue, May 14, 2013 at 6:09 PM, Joshua TAYLOR <span dir="ltr"><<a href="mailto:joshuaaaron@gmail.com" target="_blank">joshuaaaron@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">On Tue, May 14, 2013 at 11:52 AM, Taoufik Dachraoui<br>
<<a href="mailto:dachraoui.taoufik@gmail.com">dachraoui.taoufik@gmail.com</a>> wrote:<br>
</div><div class="im">> What is not true? I am not saying that stacks are conses; we can push and<br>
> pop elements from a stack and macroexpanding (PUSH 1 X) gives (SETQ X (CONS<br>
> 1 X)); so the stack, used by pop/push, in CCL is implemented<br>
> using conses; we can implement stacks using arrays (no consing) if we wish<br>
> so.<br>
><br>
> Now, the reason I am asking, is that I am implementing an interpreter for a<br>
> small language and I am using 3 stacks with a lot of consing. I wanted to<br>
> find a solution so that I can avoid consing; I recalled when we call a<br>
> function the passed parameters are pushed into a stack (implemented with<br>
> registers ESP/EBP), I am wondering if I can find a way to use the<br>
> processor's stack as for function calls to avoid consing.<br>
><br>
> Or, how do you implement a VM using CCL for a new language? (any thing<br>
> offered by CCL even if it is not<br>
> standard would be acceptable).<br>
<br>
</div>1) Although the machine stack stores things in machine memory (the<br>
program stack), when people talk about a program "cons'ing a lot" or<br>
allocating lots of memory, they're almost always talking about<br>
heap-allocated space. Even though they use the word "cons'ing", it<br>
doesn't even have to be cons cells; it's any heap allocation (so<br>
class objects, arrays, etc., are all included). This code doesn't<br>
really need any heap space, so it's not consing.<br>
2) Although the program has a stack, the program/machine stack is not<br>
(typically (does anyone know of any exceptions?)) implemented by a<br>
reusable abstract data structure known as a stack. The push/pop model<br>
happens to be the same, but the program stack is just about<br>
incrementing and decrementing the CPU's stack pointer.<br>
<span class="HOEnZb"><font color="#888888"><br>
//JT<br>
--<br>
Joshua Taylor, <a href="http://www.cs.rpi.edu/~tayloj/" target="_blank">http://www.cs.rpi.edu/~tayloj/</a><br>
</font></span><div class="HOEnZb"><div class="h5">_______________________________________________<br>
Openmcl-devel mailing list<br>
<a href="mailto:Openmcl-devel@clozure.com">Openmcl-devel@clozure.com</a><br>
<a href="http://clozure.com/mailman/listinfo/openmcl-devel" target="_blank">http://clozure.com/mailman/listinfo/openmcl-devel</a><br>
</div></div></blockquote></div><br></div>