<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br><div><div>On 10-Feb-08, at 2:53 PM, Michael van der Gulik wrote:</div><blockquote type="cite"><div class="gmail_quote"><div><br>But the execution of that block (a BlockContext?) will be added to the top of the current execution stack thus preserving the linearity of the stack, right?</div></div></blockquote><div><br class="webkit-block-placeholder"></div>Nope.&nbsp;</div><div>A stack is linear last-in first-out. In C you branch to a subroutine, a stackframe is built on the stack and you excute code based on that. When you return from the subroutine all the memory in that stackframe is known to be free to reuse immediately if wanted by the next subroutine call.&nbsp;</div><div><br class="webkit-block-placeholder"></div><div>If you can get a handle to the actual stackframe and pass it to some other code then you *cannot* reuse that memory until you have some way of knowing it is no longer needed. So now you have a sandbar in your stack and a tricky problem to solve. &nbsp;In squeak we do it the simple minded way and don't have contiguous stack but instead have actual explicitly allocated objects in the heap. That completely avoids the problem, at a cost in performance. VW uses a lot of very clever code to allow the system to live with a linearised machine compatible stack and yet present a 'proper' object to the programmer. It works, it's fast, but the complexity is at times bewildering.</div><div><br class="webkit-block-placeholder"></div><div>I'm reasonably sure this is explained in the Blue Book and certainly in various seminal papers such as the Deutsch-Schiffman 84 paper '<span class="Apple-style-span" style="-webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; "><font class="Apple-style-span" color="#000000"><span class="Apple-style-span" style="background-color: transparent;">Efficient implementation of the smalltalk-80 system' (</span></font><span class="Apple-style-span" style="-webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; "><span class="Apple-style-span" style="-webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; "><font class="Apple-style-span" color="#000000"><span class="Apple-style-span" style="background-color: transparent;"><a href="http://portal.acm.org/citation.cfm?id=800542">http://portal.acm.org/citation.cfm?id=800542</a></span></font></span><span class="Apple-style-span" style="-webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; "><font class="Apple-style-span" color="#000000"><span class="Apple-style-span" style="background-color: transparent;">) and the Miranda '87 paper 'BrouHaHa- A portable Smalltalk Interpreter'.</span></font></span></span></span></div><div apple-content-edited="true"> <span class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Palatino; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><div style="word-wrap: break-word; -khtml-nbsp-mode: space; -khtml-line-break: after-white-space; "><div><br class="khtml-block-placeholder"></div><div>tim</div><div>--</div><div>tim Rowledge; tim@rowledge.org; <a href="http://www.rowledge.org/tim">http://www.rowledge.org/tim</a></div><div>A hacker does for love what others would not do for money.</div></div><br class="Apple-interchange-newline"></span> </div><br></body></html>