Language feature to support Fluent Syntax for Static Method Calls
Archie Cobbs
archie.cobbs at gmail.com
Tue Mar 28 18:51:11 UTC 2023
On Tue, Mar 28, 2023 at 10:48 AM Ron Pressler <ron.pressler at oracle.com>
wrote:
> 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.
>
Great point - which also makes me curious how we should define the
underlying problem here.
One problem is "prettier chaining" which as Brian pointed out makes for a
relatively weak case.
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.
Just to be clear, suppose I invent this (using Kristofer's example):
public interface BetterStream<T> extends Stream<T> {
BetterStream<T> parallel(Executor e)
Set<T> toSet()
@Override
BetterStream<T> filter(Predicate<? super T> pred) // etc.
}
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?
I'm sure this has been discussed before. Curious what's the current status
of that discussion.
-Archie
--
Archie L. Cobbs
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/amber-dev/attachments/20230328/7934cc4d/attachment-0001.htm>
More information about the amber-dev
mailing list