Patrick Wright wrote:
> The idea is interesting, but, two points

Good points...

> 1) Where does it jump to? The next line after the method invocation?
> Or a finally block, if there is on? What if I haven't defined a
> finally block in the enclosing (method-calling) scope? Does it bubble
> up to some other finally in a broader scope? What if I'm starting with
> a script and haven't defined any finally at all? I guess the compiler
> could detect that a Jump was being declared (how?) and force you to
> include a finally.

The typical way a non-local return (for example) is implemented now is 
by constructing the closure containing it such that it has a unique ID 
to return to. NonLocalReturn would then be constructed with this ID, and 
the jump would bubble back out through the stack until someone 
interested in NonLocalReturn events caught it and saw it had the 
appropriate id, at which point the return value would be unwrapped and 
bubbling would stop.

So it is still more of a "throw" or "raise" or "trigger event", but the 
intention is that somewhere, someone will be interested in being the 
"landing point" for the jump.

Now this is just the brute-force way we've been implementing it. It 
could certainly be what the actual JDK7 generates as bytecode, ideally 
all behind the scenes when you do a return within a closure. However I'd 
wager there are specific optimizations that could be done to simplify 
it. For example, exception tables could be generated such that they're 
only interested in the jumps generated in that scope, both types and 
IDs, allowing other jumps to transparently pass through without the cost 
of catching and re-throwing.

Neil Gafter: I recall you advocating non-local returns, but I don't 
remember if you also advocate other types of non-local flow control like 
break or continue. Do you?

myList.each {(String element) if (element.equals("foo")) break; }

> 2) The word "jump" seems to imply a location (jump-to, jump-back-to)
> but no destination, specifically.

Perhaps it's more like "JumpAndHopeSomeoneWillCatchYouOnTheWayDown". I 
think Jump is a bit nicer though.

The accurate name would probably be "BeginStackEscape" or something similar.

- Charlie

--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/jvm-languages?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to