Tuples citizenship

kennytm kennytm at gmail.com
Fri Mar 2 11:46:09 PST 2012


"Jonathan M Davis" <jmdavisProg at gmx.com> wrote:

> It's not like using out is fantastic and tuple sucks. They both have pros and 
> cons. My point is that it's not the case that always returning tuples is 
> better, which seems to be the point that Bearophile is trying to push. There 
> _are_ downsides to returning tuples. Whether a tuple or an out parameter is 
> better depends on the function and the context in which it is used.
> 
> - Jonathan M Davis

bearophile's example (frexp, remquo) are good examples where tuple return
is better than 'out' parameters though. Another Phobos function, I think,
which should use 'out' instead of Tuples is:

-  std.file.getTimes (have the two 'out' parameters, and the function
itself returns 'void'!)

While some functions should remain using 'out':

- std.stream.InputStream.read (due to overloading)

And of course the extern(C) functions need to use 'out' instead of Tuple
return :)


More information about the Digitalmars-d mailing list