<div>OK, we're on the same wavelength. I'm glad you said "This issue</div><div>[i.e. passthrough] is orthogonal to how the multiple values are</div><div>passed" -- that's the same conclusion I've come to.</div>

<div><br></div><div>Now I wonder if we can fix the global variable (GV) design. Naive GV</div><div>had no way to suppress incorrect passthrough. But if it can be</div><div>corrected, a GV implementation would probably be simpler and more</div>

<div>efficient than <a href="http://foo.mv/arguments.callee.mv">foo.mv/arguments.callee.mv</a>.</div><div><br></div><div>The <a href="http://foo.mv">foo.mv</a> way suppresses passthrough by default and turns it on by</div>

<div>instrumenting tail calls. What about the inverse? Use a GV to enable</div><div>passthrough by default and turn it off by instrumenting *non* tail</div><div>calls. Something like:</div><div><br></div><div>  (defun foo (x y z)</div>

<div>    (values x y z))</div><div><br></div><div>  (defun baz ()</div><div>    (foo))</div><div><br></div><div>  (defun bar ()</div><div>    (foo)</div><div>    (baz))</div><div><br></div><div>  var EXTRAS = null; // global variable for MV returns</div>

<div><br></div><div>  function foo(x, y, z) {</div><div>    EXTRAS = [y, z];</div><div>    return x;</div><div>  }</div><div><br></div><div>  function baz() {</div><div>    return foo(); // passthrough enabled by default</div>

<div>  }</div><div><br></div><div>  function bar () {</div><div>    foo();</div><div>    EXTRAS = null; // instrumentation to suppress passthrough</div><div>    return baz(); // transitive passthrough is free</div><div>  }</div>

<div><br></div><div>You'd want "EXTRAS = null" after each MULTIPLE-VALUE-BIND as well, but</div><div>maybe you get this for free since the function call in a</div><div>MULTIPLE-VALUE-BIND is by definition not a tail call.</div>

<div><br></div><div>We can summarize this proposal similarly to the other one:</div><div><br></div><div>  1. Pass multiple values using a global variable</div><div>  2. Instrument every non-tail call.</div><div><br></div>

<div>It may still be too naive but it at least fixes the examples that</div><div>broke GV earlier in the thread. So, is there an example that works in</div><div><a href="http://foo.mv">foo.mv</a> but fails in GV as described above?</div>

<div><br></div><div>Dan</div><div><br></div><div>p.s. I also wonder if the recursion difficulty disappears now that we</div><div>understand passthrough better. The example was:</div><div><br></div><div>  (defun foo (x)</div>

<div>    (if (= x 1)</div><div>        (values 1 2)</div><div>        (1+ (foo (1- x)))))</div><div><br></div><div>In both the GV and <a href="http://foo.mv">foo.mv</a> designs, shouldn't foo(2) do the right thing</div>

<div>now? That recursion is a non-tail call, so GV would suppress MV</div><div>passthrough and <a href="http://foo.mv">foo.mv</a> wouldn't enable it.</div><div><br></div><br><div class="gmail_quote">On Fri, Sep 7, 2012 at 12:46 PM, Vladimir Sedach <span dir="ltr"><<a href="mailto:vsedach@gmail.com" target="_blank">vsedach@gmail.com</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Dan,<br>
<div class="im"><br>
> The only easy implementation I can think of is to mv-instrument every<br>
> tail call in the program, but that is surely overkill.<br>
<br>
</div>Yes, that's currently the only way I see to do it. This issue is<br>
orthogonal to how the multiple values are passed - in principle I<br>
could have implemented the multiple value passing instrumentation<br>
right after adding the return instrumentation code, but it didn't<br>
occur to me at the time.<br>
<br>
So to clarify, my proposal has two separate components:<br>
1. Pass multiple values on the callee function object<br>
2. Instrument every tail call<br>
<div class="HOEnZb"><div class="h5"><br>
Vladimir<br>
<br>
_______________________________________________<br>
parenscript-devel mailing list<br>
<a href="mailto:parenscript-devel@common-lisp.net">parenscript-devel@common-lisp.net</a><br>
<a href="http://lists.common-lisp.net/cgi-bin/mailman/listinfo/parenscript-devel" target="_blank">http://lists.common-lisp.net/cgi-bin/mailman/listinfo/parenscript-devel</a><br>
</div></div></blockquote></div><br>