Scoped variables

dean.long at dean.long at
Fri Dec 7 18:15:45 UTC 2018

Now might be a good time to start a discussion on how we want scoped 
variables to be created and named.  With ThreadLocals, there is a 
constructor and I can create as many unique instances as I want in the 
heap and store those instances in the instance fields of other objects.  
However with scoped variables, do we really need something so general?  
What if a scoped variable looked more like a static final field, a 
method variable, or a constant pool constant?  Some of the uses of 
ThreadLocal that seem like good candidates for scoped variables are only 
using a single "local" per class (or even package or module).

There are some good reasons for making these variables look like 
constants.  So here's a possibly crazy idea:  What if the names of 
scoped variables looked more like the enum constants in a Java enum 
type: constant singleton instances associated with a class by name.


On 12/6/18 4:18 AM, Andrew Haley wrote:
> On 12/6/18 11:55 AM, Doug Lea wrote:
>> On 12/6/18 5:27 AM, Andrew Haley wrote:
>>>> Not using Weak Refs would be the biggest win. Lots of simplifications
>>>> would be possible. But would require a new API.
>>> Yep. And right now scoped variables are a new API.
>> Can you show the API you have in mind here?
> Heavens, no. Dean Long is designing the prototype; the last thing I
> want to do is present an alternative before he's done.

More information about the loom-dev mailing list