<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div style>Thanks Matthias, </div><div style><br></div><div style>I am still a little unclear. Is this a logical result, or a result of the evaluator's rules? Or are they the same thing? </div>
<div style><br></div><div style>It wasn't until i followed the logic of (mk-length mk-length) outside the function that i saw it would replicate on and on - which i guess is what we want so we can measure lists of whatever length. </div>
<div style><br></div><div style>Likely reflecting my immaturity, now i have that result in my head, i am unclear why references to the original function stop replication at a single copy. </div><div style><br></div><div style>
is this 'original function' the above level copy of:</div><div style><br></div><div><span style>(lambda (mk-length) (Ie (lambda (x) ( (mk-length mk-length) x))))</span></div><div style><br></div><div style>I am asking as i am wondering where to focus my efforts - as this is not yet obvious to me. </div>
<div style><br></div><div style>Perhaps i need to type up some notes to clear up my thinking. </div><div style><br></div><div style>Best regards</div><div style><br></div><div style>mj</div><div style><br>On 11/02/2014, at 3:08 AM, Matthias Felleisen <<a href="mailto:matthias@ccs.neu.edu">matthias@ccs.neu.edu</a>> wrote:<br>
<br></div><blockquote type="cite" style><div><br><div><div>On Feb 10, 2014, at 4:52 PM, Matthew Johnson wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><span class="Apple-style-span" style="border-collapse:separate;border-spacing:0px"><div style="font-family:'Lucida Grande';font-size:medium">
<span style="font-family:arial,sans-serif;font-size:13px">Why does (lambda (x) (e x)) make it evaluate once and stop? I mean how<span class="Apple-converted-space"> </span></span><span style="font-family:arial,sans-serif;font-size:13px">come when the evaluator gets to the call it doesn't get stuck in a loop?</span><span style="font-family:arial,sans-serif;font-size:13px"> </span></div>
</span></blockquote><div><br></div><div><br></div><div>This explicit function gets "copied" over and over again during function calls (beta-value reductions) during an evaluation. When it is called the 'e' inside contains (references to) the original function so there is no danger that the infinite loop unfolds -- because it is waiting for the next explicit call. </div>
<div><br></div><div>;; --- </div><br><blockquote type="cite"><span class="Apple-style-span" style="font-family:arial,sans-serif;font-size:13px">but i really don't see why one would ever bother to do so. What are the benefits? the cost (hard to read / write / understand) seems high. </span></blockquote>
</div><br><div><br></div><div>CPS is a programming technique that occasionally comes up in program designs: </div><div> -- if you must implement a recursive algorithm in a language w/o recursion, cps has eliminated it -- systematically </div>
<div><span class="Apple-tab-span" style="white-space:pre"> </span>[this situation used to be common when I started teaching; now it's rare]</div><div> -- if you need to suspend a computation temporarily, the 'k' is what you don't call but stick into a known place from where to resume</div>
<div><span class="Apple-tab-span" style="white-space:pre"> </span>[web programs often have to obey this discipline: suspend k, hand control to user to fill out some form, resume k]</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>cps provides this capability -- systematically </div>
<div> -- if you need to write sophisticated interleaving of routines in a language that doesn't provide it, cps supports it -- systematically </div><div><br></div><div>The 'systematically' says that a programmer can blindly use the transformation and then modify it at some places to get things right. </div>
<div><br></div><div>;; --- </div><div><br></div><div>The transformation is also used inside of compilers as Yuhao mentions. </div></div></blockquote></body></html>