Multiple return values

bearophile bearophileHUGS at lycos.com
Tue Jan 3 16:00:05 PST 2012


Jonathan M Davis:

> I'm not saying that being able to return multiple values wouldn't be nice, but 
> in my experience, that's actually a very rare thing for languages to be able 
> to do - especially among C-based languages.

How do you count how rare is a feature need in languages that don't support that certain feature? I think you have no proof of what you are saying.
On the contrary, the only evidence I see (looking at lot of real code written by other people), with languages that do offer multiple return values, like Python, Go and others, show that people do use this feature very often and appreciate it.


> Regardless, std.typecons.Tuple is D's solution.

Maybe, but we'll need better unpacking syntax at the calling/use point:

auto (x, y) = foo();
foreach (auto (x, y); genPairs()) {

There is a pull request, plus a good amount of discussions, on this topic. 

Bye,
bearophile


More information about the Digitalmars-d mailing list