Re: Why Stream.concat is a static method - type variable contravariance

2018-10-16 Thread Tomasz Linkowski
I second that `Stream.append` would be a very useful addition, although I would definitely propose it as Stream append(Stream other) -> Stream.concat(this, other); Of course, we could also have a convenience overload like Stream append(T... values) ->

Re: Why Stream.concat is a static method - type variable contravariance

2018-10-14 Thread Tagir Valeev
Hello! Still from the practical point of view it would be really helpful to have instance methods like `Stream.append(T... elements)` and `Stream.prepend(T... elements)` (default implementation may utilize `concat`). Very often it's necessary to add one or two special elements to the stream, and

Re: Why Stream.concat is a static method - type variable contravariance

2018-10-11 Thread Brian Goetz
It would surely be convenient; I've wished for this a few times. But, there's a reason for this choice, and its not just laziness; contravariant type variables have some pretty scary challenges. See, for example, this paper:     http://www.cis.upenn.edu/~bcpierce/papers/variance.pdf in which

Re: Why Stream.concat is a static method - type variable contravariance

2018-10-11 Thread Martin Buchholz
Is this the problem discussed here? http://www.angelikalanger.com/GenericsFAQ/FAQSections/TypeParameters.html#Lower%20Bound%20Type%20Parameters%20of%20Methods (I think I ran into this myself and think the java language should be fixed to allow "Lower Bound Type Parameters of Methods") On Wed, Oct

Why Stream.concat is a static method - type variable contravariance

2018-10-10 Thread James Roper
With the work I'm doing at the moment at creating a Reactive Streams equivalent to java.util.stream, I've often wondered why Stream.concat is a static method, rather than an instance method concating the given stream onto this. But I think the reason has just dawned on me, and I wanted to confirm