Scoped values: API design

Andrew Haley aph at redhat.com
Wed Oct 2 08:12:13 UTC 2019


On 10/1/19 10:02 PM, John Rose wrote:
> On Oct 1, 2019, at 1:55 PM, Ron Pressler <ron.pressler at oracle.com <mailto:ron.pressler at oracle.com>> wrote:
>>
>> 2. Support both a lambda-based and TWR-based scopes.
>>
>> I think that the latter feature makes the API too rich, and if we
>> can get a good TWR API, wrapping it with a lambda-based one is
>> trivial, but not the other way around.

That's true.

> I agree that it’s better to start with one or the other of TWR or
> lambdas.  From an optimization point of view (I know that’s in the
> future) the lambda based form will be easier to optimize because its
> use cases are more constrained.

Yep.

> A problem with TWR APIs is that they can be used outside of TWR, and
> the library has to cope with that somehow, even if it’s just error
> detection (which by itself is a hard problem).

The latter is my primary concern. The try-with-resources version
exposes the possibility of non-nested use, which is hard to cope
with. It is also harder to specify without exposing internals. I'd
like not to have to think about it.

But I'm not going to go to the stake on this one: we can use TWR for
now and defer the final decision, even though I'm sure which way it'll
go in the end.  ;-)

-- 
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