java.util.Pair

John Rose john.r.rose at oracle.com
Thu Jul 13 21:05:14 UTC 2017


On Jul 13, 2017, at 1:39 PM, Remi Forax <forax at univ-mlv.fr> wrote:
> 
> Tuples are like an array of value types parameterized by a constant integer

The homogeneous case is pretty simple; most of what you need is
to allow a generic type to be parameterized by an integer.  C++ templates
have had that for a long time.

What's harder is to have a two-step process for type instantiation:
First, tell me the arity N, and second, for each position under that arity,
tell me the type T[i], i<N.  (And don't break type inference.)  I think
the most Java-like way to handle it might be type-functions that overload
alongside generic types.  But there are many, many ways to slice it.

C++ templates can express heterogeneous tuples:

  http://en.cppreference.com/w/cpp/utility/tuple

Typically there is a small limit to C++ tuple size, because the underlying
template implementation has its size set to the arity limit.

— John


More information about the core-libs-dev mailing list