Re: RFR: 8274412: Add a method to Stream API to consume and close the stream without using try-with-resources

2021-11-06 Thread Peter Levart
On Sun, 3 Oct 2021 11:00:25 GMT, Tagir F. Valeev wrote: > Currently, when the stream holds a resource, it's necessary to wrap it with > try-with-resources. This undermines the compact and fluent style of stream > API calls. For example, if we want to get the `List` of files inside the > direct

Re: RFR: 8274412: Add a method to Stream API to consume and close the stream without using try-with-resources

2021-11-06 Thread Peter Levart
Hi, On 11/10/2021 20:42, John Rose wrote: To summarize: We can (and should) try to model “close-debt” using interfaces. Doing so opens up the usual cans of worms with interoperability and exceptions, but still gives us a model we can contemplate. We can (and should) contemplate how such a mod

Re: RFR: 8274412: Add a method to Stream API to consume and close the stream without using try-with-resources

2021-10-16 Thread Glavo
Oh, sorry, I found that I misunderstood the closing time. I tried it in the wrong way, so I came to the wrong conclusion. Thank you for your reminder.

Re: RFR: 8274412: Add a method to Stream API to consume and close the stream without using try-with-resources

2021-10-16 Thread Remi Forax
- Original Message - > From: "Glavo" > To: "Tagir F.Valeev" > Cc: "core-libs-dev" > Sent: Samedi 16 Octobre 2021 06:25:40 > Subject: Re: RFR: 8274412: Add a method to Stream API to consume and close > the stream without using try

Re: RFR: 8274412: Add a method to Stream API to consume and close the stream without using try-with-resources

2021-10-15 Thread Glavo
I don't think it is a perfect solution to combine the close operation with the terminator operation, because there are similar issues in the intermediate operation. Consider this use case (for example only): try (var stream = Files.list(path) .flatMap(dir -> { try {

Re: RFR: 8274412: Add a method to Stream API to consume and close the stream without using try-with-resources

2021-10-15 Thread Tagir Valeev
Hello! > I am not really sure we’ve gotten the right idiom here yet. I’d like to slow > down a bit before making an API decision. > > What id suggest is capturing the proposed api and spec on list, and let’s let > this sit and bake for a bit longer. My sense is that something better may > wel

Re: RFR: 8274412: Add a method to Stream API to consume and close the stream without using try-with-resources

2021-10-11 Thread Remi Forax
se" > To: "Paul Sandoz" , "Brian Goetz" > , "Tagir F.Valeev" > > Cc: "core-libs-dev" > Sent: Lundi 11 Octobre 2021 20:42:20 > Subject: Re: RFR: 8274412: Add a method to Stream API to consume and close > the stream without using try-with

Re: RFR: 8274412: Add a method to Stream API to consume and close the stream without using try-with-resources

2021-10-11 Thread John Rose
So the purpose of TWR is to hold an object with a “close-debt” (debt of a future call to close) and pay it at the end of a block, sort of like C++ RAII (but also sort of not). But fluent syntaxes (which I like very much and hope to see more of in the future!) don’t play well with blocks, so if a f

Re: RFR: 8274412: Add a method to Stream API to consume and close the stream without using try-with-resources

2021-10-11 Thread Paul Sandoz
Hi Tagir, Do you mind if we slow down on this and let the idea bake somewhat, captured in this thread/issue/PR(draft). I am always a little wary of compact-only or fluent-only methods, as I find them harder to justify. In this case I think there might be something more with regards to a patter

Re: RFR: 8274412: Add a method to Stream API to consume and close the stream without using try-with-resources

2021-10-10 Thread Brian Goetz
I am not really sure we’ve gotten the right idiom here yet. I’d like to slow down a bit before making an API decision. What id suggest is capturing the proposed api and spec on list, and let’s let this sit and bake for a bit longer. My sense is that something better may well emerge if we do

Re: RFR: 8274412: Add a method to Stream API to consume and close the stream without using try-with-resources

2021-10-09 Thread Remi Forax
- Original Message - > From: "Tagir F.Valeev" > To: "core-libs-dev" > Sent: Lundi 4 Octobre 2021 08:51:55 > Subject: RFR: 8274412: Add a method to Stream API to consume and close the > stream without using try-with-resources > Currently,

Re: RFR: 8274412: Add a method to Stream API to consume and close the stream without using try-with-resources

2021-10-09 Thread Tagir F . Valeev
On Sun, 3 Oct 2021 11:00:25 GMT, Tagir F. Valeev wrote: > Currently, when the stream holds a resource, it's necessary to wrap it with > try-with-resources. This undermines the compact and fluent style of stream > API calls. For example, if we want to get the `List` of files inside the > direct

RFR: 8274412: Add a method to Stream API to consume and close the stream without using try-with-resources

2021-10-03 Thread Tagir F . Valeev
Currently, when the stream holds a resource, it's necessary to wrap it with try-with-resources. This undermines the compact and fluent style of stream API calls. For example, if we want to get the `List` of files inside the directory and timely close the underlying filehandle, we should use some