<div dir="auto"><div>I'm not sure if this was discussed before, but this problem was big enough that other languages did introduce language features to help with it. It is important to emphasize that like Ron said, Java is *very* conservative, so "other did it" shouldn't be read as "they did it so Java should also offer a solution" but rather it should be read as a sign that this conversation has substance.</div><div dir="auto"><br></div><div dir="auto">Kotlin, for example, introduced a keyword for delegating a reference (although I would argue that they took the delegating ship too far, and gave it a bit too much power).</div><div dir="auto"><br></div><div dir="auto">But I don't necessarily think that "wrapping" is the correct description of the problem, I think that "it is hard to compose in Java" is a better description (I'm talking about composing objects, not about composing effects and all of the fun higher order talks).</div><div dir="auto"><br></div><div dir="auto">This broader problem I personally feel in 2 places: in wrapping objects (e.g. like creating enhanced streams) and in life-time management, e.g. there is no easy way to compose few resources (it is not impossible, but it very cumbersome, especially when you are trying to communicate with a third party library).</div><div dir="auto"><br><div class="gmail_quote" dir="auto"><div dir="ltr" class="gmail_attr">On Tue, Mar 28, 2023, 21:52 Archie Cobbs <<a href="mailto:archie.cobbs@gmail.com">archie.cobbs@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div dir="ltr">On Tue, Mar 28, 2023 at 10:48 AM Ron Pressler <<a href="mailto:ron.pressler@oracle.com" target="_blank" rel="noreferrer">ron.pressler@oracle.com</a>> wrote:</div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">As usual, the main challenge is understanding what exactly is the problem here — is this a specific issue with CF and Stream or something more general — and if there is a general problem, what exactly is it, and does it justify a change to the language. Only after we answer that can we consider adding a language feature.<br></blockquote><div><br></div>Great point - which also makes me curious how we should define the underlying problem here.<br clear="all"></div><div><br></div><div>One problem is "prettier chaining" which as Brian pointed out makes for a relatively weak case.</div><div><br></div><div>What about another problem, which is that in Java it's too hard to "wrap" something with new functionality? I.e., this is the same problem extensions try to solve.<br></div><div><br></div><div>Just to be clear, suppose I invent this (using Kristofer's example):</div><div><br></div><div style="margin-left:40px"><span style="font-family:monospace">public interface BetterStream<T> extends Stream<T> {</span></div><div style="margin-left:40px"><span style="font-family:monospace">    BetterStream<T> parallel(Executor e)<br>    Set<T> toSet()</span></div><div style="margin-left:40px"><span style="font-family:monospace">    <a class="gmail_plusreply" id="m_6301420002199451678plusReplyChip-3" rel="noreferrer">@Override</a><br></span></div><div style="margin-left:40px"><span style="font-family:monospace">    BetterStream<T> filter(Predicate<? super T> pred) // etc.<br></span></div><div style="margin-left:40px"><span style="font-family:monospace">}<br></span></div><div><br></div><div>It's not easy to wrap Streams I encounter to convert them into BetterStreams. I agree with Brian that "API designers should control their API's" so I suppose we're talking about a true "wrap", not a "monkey patch". You can do a "wrap" today but it's tedious and brittle. Could the language make it easier somehow?<br></div><div><br></div><div>I'm sure this has been discussed before. Curious what's the current status of that discussion.<br></div><div><br></div><div>-Archie</div><div><br></div><span>-- </span><br><div dir="ltr">Archie L. Cobbs<br></div></div>
</blockquote></div></div></div>