Primitive streams and optional (original) (raw)

Doug Lea dl at cs.oswego.edu
Tue Nov 27 07:27:30 PST 2012


On 11/27/12 09:33, Tim Peierls wrote:

On Nov 26, 2012, at 10:12 PM, Sam Pullara <spullara at gmail.com> wrote:

I still prefer having one method that returns a "thing" that can be used, uniformly and in a fluent-like manner, to do determine whether a result is available or absent.

In which case (as Howard Lovatt almost said on lambda-dev list), you are either a closet smalltalk programmer, so want ifTrue:/ifFalse blocks, or a closet lambda-calculus programmer, in which case you want multiple continuations. Which are almost the same thing! So maybe you want:

U withFirst(Predicate p, Function<T,U> ifPresent, Supplier ifAbsent);

in addition to the plain reduction-based version.

Me, too, if by "thing" you mean "Optional". It solves so many problems:

Tim: I love Optional with Value types. Vastly better than boxing. I hate it as a half-object/half-value compromise. If/when Java supports true value types, I will be first in the "let's do Optional right" line. But until then, I'm still dead set against it.

-Doug



More information about the lambda-libs-spec-observers mailing list