The implementation looks good! It is indeed possible to implement ,\_MR
via exceptions, local continuations, or prompts as Anthony has here.
While I can't speak for Olin, I expect that his point is that
implementing the transformations we discuss in the paper practically
would require a (possibly byte-code) compiler that knew about
multi-returns internally. I don't know Racket internals well enough to
discuss prompts, but I imagine they don't allow the kinds of tail-call
optimizations that such a compiler would.<br>
<br>Dave<br><br><div class="gmail_quote">On Tue, Feb 21, 2012 at 9:32 AM, J. Ian Johnson <span dir="ltr"><<a href="mailto:ianj@ccs.neu.edu">ianj@ccs.neu.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
Perhaps I remembered wrong about interpretation, but I do know he said that he didn't have a good implementation story - he must not have been very satisfied with that journal article.<br>
<div class="im HOEnZb"><br>
-Ian<br>
----- Original Message -----<br>
</div><div class="HOEnZb"><div class="h5">From: "Sam Tobin-Hochstadt" <<a href="mailto:samth@ccs.neu.edu">samth@ccs.neu.edu</a>><br>
To: "J. Ian Johnson" <<a href="mailto:ianj@ccs.neu.edu">ianj@ccs.neu.edu</a>><br>
Cc: "Anthony Carrico" <<a href="mailto:acarrico@memebeam.org">acarrico@memebeam.org</a>>, <a href="mailto:users@racket-lang.org">users@racket-lang.org</a><br>
Sent: Tuesday, February 21, 2012 8:45:06 AM GMT -05:00 US/Canada Eastern<br>
Subject: Re: [racket] Multi-return Function Call<br>
<br>
That seems very surprising, since the journal paper (JFP 2006) about<br>
MRLC talks a lot about implementation strategies, and includes<br>
performance measurements for a compiler that implements MRLC.<br>
<br>
I think Anthony's implementation resembles the implementation in terms<br>
of exceptions discussed in section 11.1 of that paper.<br>
<br>
On Tue, Feb 21, 2012 at 8:15 AM, J. Ian Johnson <<a href="mailto:ianj@ccs.neu.edu">ianj@ccs.neu.edu</a>> wrote:<br>
> I don't have the time right now to go through your implementation, but I will say that I've talked to Olin directly about implementing \lambda_{MR} and he answered that it he could not think of any good implementation story beyond interpretation.<br>
><br>
> -Ian<br>
> ----- Original Message -----<br>
> From: "Anthony Carrico" <<a href="mailto:acarrico@memebeam.org">acarrico@memebeam.org</a>><br>
> To: <a href="mailto:users@racket-lang.org">users@racket-lang.org</a><br>
> Sent: Monday, February 20, 2012 8:21:06 PM GMT -05:00 US/Canada Eastern<br>
> Subject: [racket] Multi-return Function Call<br>
><br>
> It is only 60 LOC, so go ahead and take a look:<br>
> <a href="https://github.com/acarrico/multi" target="_blank">https://github.com/acarrico/multi</a><br>
><br>
> README:<br>
><br>
> AUTHOR: Anthony Carrico <<a href="mailto:acarrico@memebeam.org">acarrico@memebeam.org</a>><br>
><br>
> This is an implementation of Olin Shivers'/David Fisher's<br>
> "Multi-return Function Call". I'll quote from the abstract of their<br>
> paper:<br>
><br>
> "It is possible to extend the basic notion of 'function call' to<br>
> allow functions to have multiple return points. This turns out to be<br>
> a surprisingly useful mechanism. This article conducts a fairly<br>
> wide-ranging tour of such a feature..."<br>
><br>
> The paper is at:<br>
> <a href="http://www.ccs.neu.edu/home/shivers/papers/mrlc.pdf" target="_blank">http://www.ccs.neu.edu/home/shivers/papers/mrlc.pdf</a><br>
><br>
> I'm not aware of any published implementation of this feature. I wrote<br>
> this version after looking at the language creation features in<br>
> Racket. I was wondering how Racket might host languages with features<br>
> that weren't supported by its primitives and multi came to mind, but<br>
> after reading through the Racket documentation on continuations, I<br>
> began to think that it was possible to implement multi as a plain old<br>
> macro with continuation marks and prompts.<br>
><br>
> My syntax has minor differences from the paper. Return points are<br>
> indexed from ZERO, not one, since that is how vectors (etc.) are<br>
> indexed in Scheme. Also, the indexed return point syntax isn't<br>
> prefixed with #, and the lambda return point syntax doesn't have a<br>
> lambda keyword.<br>
><br>
> Look through test.rkt for a bunch of examples.<br>
><br>
> ISSUES:<br>
><br>
> I'd like to hear from someone who knows Racket really well to tell me<br>
> if I'm barking up the wrong tree. Is there a better way to provide<br>
> multi? Is what I have done reasonable?<br>
><br>
> The macros could be better, and give better messages, etc. Please send<br>
> a patch if you are good at that sort of thing.<br>
><br>
> The multi macro would need to be improved to capture the super tail<br>
> call semantics:<br>
> * A prompt should only be used when introducing lambda return points.<br>
> * Unused prompts could be popped off the "stack" before setting<br>
> up new return points.<br>
><br>
> --<br>
> Anthony Carrico<br>
><br>
><br>
> ____________________<br>
> Racket Users list:<br>
> <a href="http://lists.racket-lang.org/users" target="_blank">http://lists.racket-lang.org/users</a><br>
> ____________________<br>
> Racket Users list:<br>
> <a href="http://lists.racket-lang.org/users" target="_blank">http://lists.racket-lang.org/users</a><br>
<br>
<br>
<br>
--<br>
sam th<br>
<a href="mailto:samth@ccs.neu.edu">samth@ccs.neu.edu</a><br>
<br>
____________________<br>
Racket Users list:<br>
<a href="http://lists.racket-lang.org/users" target="_blank">http://lists.racket-lang.org/users</a><br>
</div></div></blockquote></div><br>