Scope locals
Remi Forax
forax at univ-mlv.fr
Fri May 7 14:51:10 UTC 2021
Hi Andrew,
i've taken a look to the API.
I wonder if it is necessary to allow to register more than one scope local variable before entering the scope in the API given that using a primitive class (from Valhalla) to group the values should be slightly more efficient that using several scope locals.
The first example can be written
primitive record Point(int x, int y) {}
static final ScopeLocal<Point> POINT_LOCAL = ScopeLocal.forType(MyType.class);
{
ScopeLocal.run(POINT_LOCAL, new Point(...), () -> {
... code that uses POINT_LOCAL.get() ...
});
}
Rémi
----- Mail original -----
> De: "Andrew Haley" <aph at redhat.com>
> À: "loom-dev" <loom-dev at openjdk.java.net>
> Envoyé: Vendredi 7 Mai 2021 14:03:35
> Objet: Re: Scope locals
> Hi,
>
> I'm delighted that you've picked this up. It really made my morning!
>
> On 5/5/21 11:54 PM, Paul Sandoz wrote:
>>
>> - I like the conciseness of the API, and that of the
>> implementation. It could potentially stand on its own separate from
>> virtual threads as an independent JEP.
>
> Great. Draft JEP is https://github.com/theRealAph/ScopeLocals#readme
>
> I've drafted a much longer reply to all your points, but I'm going to
> hold back for a short while because you've suggested a great idea to
> simplify the API, and I first want to see if it works.
>
> Thanks,
>
> --
> Andrew Haley (he/him)
> Java Platform Lead Engineer
> Red Hat UK Ltd. <https://www.redhat.com>
> https://keybase.io/andrewhaley
> EAC8 43EB D3EF DB98 CC77 2FAD A5CD 6035 332F A671
More information about the loom-dev
mailing list