Treating them as an array would make the grammar messy, I think. The
compiler would have to check whether what is being returned is an
array type or a multiple value type.
Naming them doesn't work, because 1) the return types aren't
necessarily named and 2) you could return a type that genuinely has
field x.
I am a compilers amateur, but I believe these kinds of ambiguities are
something the go team is trying to avoid.
If we were to do anything at all here, it would have to be something
that is not overloaded elsewhere.
a.plus(b)_0, a.plus(b)#0 come to mind. the _0 could work because, even
though _ is a valid character for identifiers, you would never have an
identifier immediately after a function call. there would be a ',' or
a ';' first. # because I don't think # is used anywhere else, though
perhaps it is with some obscure bit shifting notation...those always
get me.
I think either make intuitive sense - _0 because in latex that means
subscript zero, a common way of indexing vectors, and #0 because it's
the thing's #0th element.
For when a type *is* named, a.plus(b)_x or a.plus(b)#x could make
sense.
Could also do something like
a.plus(b)# for the first, a.plus(b)## for the second, etc, but that
could get ugly fast.
Though I think that a.plus(b)_<number or identifier> would be elegant
and fairly nice :)
Leaves the door open to things like
x, y = a.plus(b)_(0,2)
if there were three returned values and you wanted the first and last,
though I see this as less useful than a simple "extract one" scheme.
- John