Ben Evans wrote:
>  If I'm following this thread right, then what is really meant by TCO is 
> not "JVM implementations are allowed to spot that a certain pattern of 
> bytecodes (eg 0xb6 0xXY 0xZW 0xb0) are a tail-call and MAY be optimised 
> by the JITter" but "a certain, not currently permitted, sequence of 
> bytecodes MUST be optimised as a tail-call so as to not grow the stack"
> 
> The MUST condition allows us to make semantic guarantees about certain 
> recursive cases not blowing up the stack - important for functional 
> languages. 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).
> 
> The reason why one implementation can't just unilaterally introduce it 
> is that the pattern does not cuurently constitute valid Java code as per 
> the spec, and the results of that - ie trying to run code compiled with 
> the new bytecode form on a JVM which doesn't support it would not be good.

This is a good description of the problem. Any JVM could implement 
support for tail calls as long as it was not outwardly apparent (and 
really, Hotspot et al eliminating several calls in cases where much of 
the recursion chain can be inlined is a limited example of this). But 
the MUST guarantee does make the support apparent and explicit, and so 
it needs to be done uniformly across JVMs.

- Charlie

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

Reply via email to