www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Re: Multi typed value return.

reply bearophile <bearophileHUGS lycos.com> writes:
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
May 12 2011
parent Matthew Ong <ongbp yahoo.com> writes:
On 5/13/2011 12:47 AM, bearophile wrote:
 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

Yes. Thanks for the Tuple and yes. That will do the job for the time being. It does beat manually creating a struct and change that later also. -- Matthew Ong email: ongbp yahoo.com
May 16 2011