Function parameter order
Sam Pullara
spullara at gmail.com
Mon Nov 12 19:34:05 PST 2012
This proposal makes a lot of sense to me. Not sure how nice it will look in the APIs that use them but it will be obvious what is going on and matches my expectations on type ordering.
Sam
On Nov 12, 2012, at 7:06 PM, "Raab, Donald" <Donald.Raab at gs.com> wrote:
> FWIW, I checked in an updated version of my alternate proposal on the branch of our kata code base where I have been testing the Java 8 Lambda changes. I thought this would make it easier to view than pasting large amounts of text in email. I’ve included Tim’s recommendation of adding ToXYZ at the end of each type, instead of having special types for each primitive. I have to admit to liking this better now having tried it with a slight variation.
>
> https://github.com/goldmansachs/gs-collections-kata/blob/solutions-java8-jcf/src/test/java/blocks/LambdaTest.java
>
> The proposal now looks very similar to Doug’s Ops alternative, with the clear separation of Function, Procedure and Predicate and the more distinct separation of the ToType methods.
>
> https://github.com/goldmansachs/gs-collections-kata/blob/solutions-java8-jcf/src/test/java/blocks/Function.java
> https://github.com/goldmansachs/gs-collections-kata/blob/solutions-java8-jcf/src/test/java/blocks/Predicate.java
> https://github.com/goldmansachs/gs-collections-kata/blob/solutions-java8-jcf/src/test/java/blocks/Procedure.java
>
> I think this alternative has a very interesting and potentially beneficial grouping side effect in IDEs.
>
>
> From: tpeierls at gmail.com [mailto:tpeierls at gmail.com] On Behalf Of Tim Peierls
> Sent: Wednesday, November 07, 2012 12:32 PM
> To: Raab, Donald [Tech]
> Cc: Brian Goetz; lambda-libs-spec-experts at openjdk.java.net
> Subject: Re: Function parameter order
>
> I've included 3 tests below. One for Procedure, Function and IntFunction. Predicate will be like Procedure (only one class) so I didn't include it, although technically, it could be handled with a BooleanFunction. I prefer Predicate, but I wonder whether both BooleanFunction and Predicate are useful.
>
> It's important to have Predicate. Question is whether there's any use for BooleanFunction other than completeness.
>
>
>
> I will assume if you can't reason about it without asking lots of questions, then it is not a good proposal.
>
> I got it reasonably quickly, so I think it's a reasonable proposal.
>
>
> Return type is the last parameter in the list of generic types in the case of Function, so hopefully that explains one little thing that might be hard to figure out with all Strings in the examples.
>
> I could live with this but would find it easier to read if there were little words to delimit and clarify things for casual readers, e.g., Function.OfType2ToInt.
>
> --tim
More information about the lambda-libs-spec-observers
mailing list