Hi Peter!

On 3/15/19 1:24 AM, Peter Levart wrote:


On 3/15/19 9:03 AM, fo...@univ-mlv.fr wrote:
      * @since 13
      */
     interface Once {}


What do you think of that?
It's not clear to me if an annotation, available at runtime, is not a better fit. Anyway, i'm not sure not sure introducing such interface/annotation worth its maintenance cost, as you said the use case is pretty narrow.


It is narrow, but in a situation like that, where you want to code an optimal generic algorithm and all you have access to is an Iterable, there's no other way (short of providing additional methods, which is ugly). Just think of this situation. You have to decide upfront if you need to buffer the elements obtained from 1st iteration or not, but 1st iteration always succeeds...

Can you please explain how the interface Once would help to solve this?
If an Iterable does not implement Once, it does not mean it allows multiple passes, right?

With kind regards,
Ivan

Annotations are not suitable for that as the check has to be quick and they don't play well with inheritance etc...

Peter



--
With kind regards,
Ivan Gerasimov

Reply via email to