Scoped variables

Ron Pressler ron.pressler at
Tue Dec 4 16:02:15 UTC 2018

Well, dynamic binding has the problem of both being associated with some 
stack (among many concurrent ones) as well as the number and identity of variables 
in scope varies depending on the particular call path (because it’s, well, dynamic).

I am, therefore, not aware of an implementation of the concept that does not involve
some kind of hash-map lookup (or worse). The question is how fast that map lookup 
can be made to be.


On December 4, 2018 at 10:39:46 AM, Andrew Haley (aph at wrote:


On 12/3/18 6:24 PM, Ron Pressler wrote:  
> Yes, scope variables are indeed orthogonal to fibers (although we would like to  
> combine them with structured concurrency).  

> Dean Long has started working on an early prototype, which he’ll  
> present hopef ully soon.  

Aw, I was too late. Never mind :-)  

I was looking for something interesting and reasonably self-contained  
to do.  

> While scope locals are certainly superior to TLs from a programming  
> perspective, I’m not sure beating them on sheer performance would be  
> so easy. But If you have some ideas on how to do that, they would be  
> most welcome.  

I'm really shocked by that. ThreadLocals are *horrible*: twelve memory  
loads and two conditional branches in the best case. I see John Rose's  
comments about the cost of maintaining the footprint cost of today's  
ThreadLocals, but the idea of searching down the stack for a binding  
isn't going to delight anyone.  

I don't want to poison the well before we've seen Dean Long's  
prototype, though. That would be unfair, so I'll wait.  

Andrew Haley  
Java Platform Lead Engineer  
Red Hat UK Ltd. <>  
EAC8 43EB D3EF DB98 CC77 2FAD A5CD 6035 332F A671  

More information about the loom-dev mailing list