[External] : Re: Single Thread Continuation

Robert Engels rengels at ix.netcom.com
Tue Jul 11 15:36:31 UTC 2023


Long-term it seems that Java could close AutoClosable Iterators as a function of scoping. (E.g as those returned from Iterable). 

There was a VERY long discussion of this very topic (including generators) in the Go forums fairly recently. 

> On Jul 11, 2023, at 10:32 AM, Robert Engels <rengels at ix.netcom.com> wrote:
> 
> I don’t think it is any different than a database connection and a result set. You CAN close these but typically the system will perform fine if you don’t. The “costly” backend usually has alternative ways of dealing with “lazy” cleanup. 
> 
>>> On Jul 11, 2023, at 8:57 AM, Andrew Haley <aph-open at littlepinkcloud.com> wrote:
>>> 
>>> On 7/11/23 14:49, Robert Engels wrote:
>>> You don’t need a closable iterator. It is trivial to modify the code I provided to make the outer generator instance AutoClosable to be used with TwR and if the iterator is used after the outer is closed it fails with an IllegalStateException (or NoSuchElementException with ‘generator closed’ as the cause.
>> 
>> Sure. All I'm saying is that a generator must be closable in some way and
>> that the consumer is responsible for doing that.
>> 
>> -- 
>> 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