> On Aug 13, 2020, at 9:42 AM, Brian Goetz <[email protected]> wrote:
>
> . . .
>> i should wuth by example a method minMax that returns both the minimum and
>> the maximum of an array
>
>> public static (int min, int max) minMax(int[] array) {
>
> Nope. Not going there. I went down this road too, but multiple-return is
> another one of those “tease” features that looks cool but very quickly looks
> like glass 80% empty. More fake tuples for which the user will not thank us.
> And, to the extent we pick _this particular_ tuple syntax, the reaction is
> “well then WTF did you do records for?” Having records _and_ structural
> tuples would be silly. We’ve made our choice: Java’s tuples are nominal.
> . . .
>
> There’s room for an “anonymous tuple” feature someday, maybe, but we don’t
> need it now.
I think it is important that we first get the right story for general nominal
tuples.
And I also recommend that we then quickly nail down some turf by immediately
putting into the library (say, in java.util) some standard record classes
Pair<A,B>(A first, B second)
Triple<A,B,C>(A first, B second, C third)
Quadruple<A,B,C,D>(A first, B second, C third, D fourth)
. . .
Octuple<A,B,C,D,E,F,G,H>(A first, B second, C third, D fourth, E fifth,
F sixth, G seventh, H eighth)
Once that is done, I believe it would be very easy, if we ever care to do it,
to introduce
(a, b, c)
in an expression context as a syntactic abbreviation for
new java.util.Triple(a, b c)
and
(A, B, C)
in a type context as a syntactic abbreviation for
java.util.Triple<A,B,C>
N’est-ce pas?
(This is where I get to recount once again my little story about that fact that
way back in 1995, I persuaded James and the Java team to remove C's comma
operator from Java on the grounds that (a) in C it’s used only in macros, which
Java doesn’t have, and in `for` statements, which can be handled specially in
the syntax, and (b) it would leave open the possibility of supporting tuples
later. And 25 years later it’s still an option.)