On Thu, Apr 2, 2009 at 6:11 PM, Per Bothner <p...@bothner.com> wrote:

>
> A number of JVM-based languages implement tail-call elimination.
> The problem is that you have to compile your functions into a
> different calling convention that the natural. which has some
> performance cost, and complicates interoperability.
>
> Kawa supports two calling conventions, selected by a command-line
> switch:
> (1) The "obvious" one where a Scheme function call is translated to
> a plain method call, with the methods return value being the Scheme
> function's result.
> (2) Full tail-call support using an extra hidden method argument
> that points to a CallContext object.  A call is translated thus:
> - The parameters are evaluated, and copied into the CallContext.
> - The function to be called is evaluated and saved in the CallContext.
> - The calling function returns.
> - That function's caller implements a "trampoline" (see
> http://en.wikipedia.org/wiki/Tail_recursion and
> http://en.wikipedia.org/wiki/Trampoline_%28computers%29 )
> which then calls the function saved in the CallContext.
> - The callee methods extracts its arguments from the CallContext.
>
> This is obviously a bit slower, but not so much slower as
> to be unusable.  (The CallContext API isn't as tweaked as
> it should be.)
>
> On 04/02/2009 09:46 AM, Ben Evans wrote:
>  > As I understand it, it is not currently possible to implement
>  > Scheme fully on the JVM, as the Scheme spec requires compilers to
>  > make a form of the above MUST guarantee (I am not a Scheme head, so >
>  > if this is too much of a simplification, someone please put me right).
>
> You're right about Scheme, but wrong about it not being possible
> to implement Scheme fully on the JVM.


Ah yes, I should have said "whilst maintaining standard calling
conventions".

Thanks for the catch,

Ben

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "JVM 
Languages" group.
To post to this group, send email to jvm-languages@googlegroups.com
To unsubscribe from this group, send email to 
jvm-languages+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/jvm-languages?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to