From: "Leopold Toetsch via RT" <[EMAIL PROTECTED]>
   Date: Mon, 30 Jan 2006 05:48:42 -0800

   Bob Rogers (via RT) wrote:

   >    It seems that Continuation needs the same set_address magic as
   > Exception_Handler in order to return values. 

   Yep. At least as long we don't have better support for creating
   limited continuations that are able to return some results.

I'm afraid I don't follow.  What would you consider better?

   There is of course the 'standard' way to achieve this effect with a
   helper subroutine 'call-with-current-continuation', but there are
   probably some more HLL semantics, which translate to the usage of the
   patch.

Seems to me that call-with-current-continuation uses the identical
underlying mechanism as what I've been trying to do with Continuation,
at least as "implemented" by the t/op/lexicals.t "closure 4" test case.
It invokes its continuation in the same way as the new "set_args via
explicit continuation" test (invokecc_p in both cases) -- but has always
worked just because it has always used a RetContinuation instead of a
Continuation.  I think that's the only real difference.

   But, FWIW, I am coming around to the view that continuations
shouldn't ever be invoked like this.  Plain function calling is likely
to confuse optimizers, since they won't understand that you don't ever
expect to return.  I was about to propose a new op when I discovered
that tailcall works just fine for this purpose (see below).  I hope to
document this, so that it can become the standard idiom.

   We may want to go farther, though.  Since optimizers could still lose
on code that doesn't conform to this convention, perhaps Parrot should
enforce the distinction by throwing an error if invokecc is used to call
something that can't return?

                                        -- Bob

------------------------------------------------------------------------
Index: t/op/lexicals.t
===================================================================
--- t/op/lexicals.t     (revision 11383)
+++ t/op/lexicals.t     (working copy)
@@ -651,7 +651,7 @@
      our_try = find_lex "try"
      $P2 = find_lex "choices"
      $P3 = our_try($P2)
-     our_cc($P3)
+     .return our_cc($P3)
 .end
 
 .sub _fail :outer(main)

Reply via email to