Multiple return values...

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Sat Mar 10 19:04:40 PST 2012


On 3/10/12 4:37 AM, Manu wrote:
> I still fundamentally see a clear divide between a Tuple, which is a
> deliberately structured association of multiple values, and 'multiple
> return values' which is an explicit non-association of multiple returned
> things.

There is no difference. A Tuple is a product type, exactly like 
superposing arbitrary values together.

> You need to address that principle before I can begin to accept the idea
> of abusing a structured tuple as a substitute for this important
> language feature.
>
> My analogy is the function argument list. You don't think of the
> arguments you pass to a function as a Tuple (is it implemented
> internally in this way? if so, it is well hidden, and perhaps similar
> magic can be done...)
> You pass, TO a function, multiple un-associated values.

This analogy is tenuous for D because functions are defined to return 
one type, e.g. typeof(fun(args)) is defined. Once we get into 
disallowing that for certain functions, we're looking at major language 
changes for little benefit.


Andrei


More information about the Digitalmars-d mailing list