Scoped variables

Brian Goetz brian.goetz at
Thu Dec 6 18:57:44 UTC 2018

Let me toss in a few more kinds of stack-based cookies that we stumbled 
over in Lambda, to be kept in the back of our heads as we design such a 
mechanism.  There were three (subtly) related features that were 
requested in Lambda, which we did not implement:

  - capturing mutable locals
  - nonlocal return from lambdas
  - exception transparency

While we could argue (but shouldn't here) whether these features are 
good ideas or bad ideas on their own, what they had in common was: the 
lambdas that were captured were somehow "stack bound". That is, they had 
references into the stack of the capturer, and therefore, they had some 
implicit constraints: they could only be invoked on the capturing 
thread, while the capturing frame was still on the stack.  After that 
frame is unwound, they need to turn into pumpkins; if called from 
another thread, they need to fail fast (throw some sort of 

The ability to capture a frame local that describes the capture frame, 
and validate at invocation time that the calling stack still contains 
that frame, is a building block on which all these features could be built.

On 12/4/2018 7:33 PM, John Rose wrote:
> I like the thought here:  There are several kinds of "cookies" you might need
> to look for in a stack walk. The JVM should unify them; the reward will be
> simpler code and better return on investment in JIT optimizations.  Stack
> based access control is today's such cookie.

More information about the loom-dev mailing list