Multi typed value return.

bearophile bearophileHUGS at lycos.com
Thu May 12 09:47:09 PDT 2011


Matthew Ong:

> Any plan to support this really cool feature of Multiple type
> return value?

Multiple return values is a very handy feature, I use it quite often in Python. It makes the code more natural and readable, and avoids some troubles given by "out" arguments. In the D standard library there is a struct-based Tuple. So what's desired is just syntax sugar for the unpacking of a Phobos Tuple, useful for tuples in general, tuples returned by functions, and unpacking of tuples in the foreach, like in foreach((x,y); foo()). We have discussed about tuple unpacking this some time ago and I think Walter & Andrei don't hate the idea of this syntax sugar, but I presume it's not for D2.

Bye,
bearophile


More information about the Digitalmars-d mailing list