Re: 'Find' method for Iterable

2020-11-17 Thread Remi Forax
- Mail original - > De: "Brian Goetz" > À: "Michael Kuhlmann" , "core-libs-dev" > > Envoyé: Mardi 17 Novembre 2020 20:44:17 > Objet: Re: 'Find' method for Iterable > On 9/21/2020 4:08 AM, Michael Kuhlmann wrote: >> But a

Re: 'Find' method for Iterable

2020-11-17 Thread Brian Goetz
On 9/21/2020 4:08 AM, Michael Kuhlmann wrote: But after thinking about it, I'm now convinced that it would be a bad idea. Because it extends the scope of this small, tiny Iterable interface to something bigger which it shouldn't be. This response captures the essence of the problem.  You m

Re: 'Find' method for Iterable

2020-11-17 Thread Nir Lisker
I think that the discussion is still at the level of if it's an acceptable addition and not yet at where to implement it. I gave my reasoning in response to Stuart's points as to what I think is acceptable and what isn't. Whether the java.lang package has special status is a bit ahead of where we a

Re: 'Find' method for Iterable

2020-11-11 Thread Justin Dekeyser
Hello all, Were those downsides seriously considered and strongly argued against? : (1) Iterable belongs to java.lang so, at least from how it is usually approached, it's a feature at the very level of the language, not a util feature like Collection. Adding a find on it, is it really relevant, o

Re: 'Find' method for Iterable

2020-11-10 Thread Nir Lisker
Did this discussion get lost? On Sun, Sep 20, 2020 at 1:27 AM Nir Lisker wrote: > While it might not be difficult to add a find() method to Iterable, why >> limit it to >> the find operation, and what about all the other operations available on >> Stream? > > > Good question. I would say it's a

Re: 'Find' method for Iterable

2020-09-21 Thread Justin Dekeyser
I'm also thinking about something: If `T find()` gets implemented on `Iterable` with the contract that this method always ends, this implies that the amount of elements available in the Iterable is finite, which makes it possible to define a `int size()` by providing a trivial predicate. This woul

Re: 'Find' method for Iterable

2020-09-21 Thread Justin Dekeyser
Hi all, Correct me if I'm wrong, but isn't the goal of Iterable be used as argument in a enhanced for-loop, that is: just allow a enhanced syntax. (Similarly, AUtoCloseable is what allows the try-with-resource syntax; Throwable is what allows the throw syntax) As such, isn't it out of scope of It

Re: 'Find' method for Iterable

2020-09-21 Thread Michael Kuhlmann
Hi Nir, at first I thought "Wow, it would be really cool to have that method in Iterable! Why isn't it there already?" But after thinking about it, I'm now convinced that it would be a bad idea. Because it extends the scope of this small, tiny Iterable interface to something bigger which it

Re: 'Find' method for Iterable

2020-09-19 Thread Nir Lisker
> > While it might not be difficult to add a find() method to Iterable, why > limit it to > the find operation, and what about all the other operations available on > Stream? Good question. I would say it's a matter of how much it is used and what it takes to implement it. The find operation is a

Re: 'Find' method for Iterable

2020-09-18 Thread Nir Lisker
> > But a Stream cleanly separate the lazy side effect free API from the > mutable one (Collection) and can be optimized better by the VM (it's a push > API instead of being a pull API). No doubt, but a stream also creates overhead and is more cumbersome to use in the example I gave. Of course, I

Re: 'Find' method for Iterable

2020-09-16 Thread Stuart Marks
On 9/16/20 1:59 PM, Remi Forax wrote: - Mail original - De: "Nir Lisker" À: "core-libs-dev" Envoyé: Lundi 14 Septembre 2020 20:56:27 Objet: 'Find' method for Iterable Hi, This has probably been brought up at some point. When we need to find an item in a collection based on its p

Re: 'Find' method for Iterable

2020-09-16 Thread Remi Forax
- Mail original - > De: "Nir Lisker" > À: "core-libs-dev" > Envoyé: Lundi 14 Septembre 2020 20:56:27 > Objet: 'Find' method for Iterable > Hi, > > This has probably been brought up at some point. When we need to find an > item in a collection based on its properties, we can either do it