Tuples citizenship

Jonathan M Davis jmdavisProg at gmx.com
Thu Mar 1 14:33:10 PST 2012


On Thursday, March 01, 2012 17:08:44 bearophile wrote:
> I think std.typecons.Tuples merit to be a little more citizens in D and
> Phobos. I think reducing the usage of "out" argument, and replacing them
> with a tuple result, will avoid mistakes and make the code look better. In
> std.math there are functions that maybe are better to use
> std.typecons.Tuple:
> 
> pure nothrow @trusted real frexp(real value, out int exp);
> ==>
> pure nothrow @trusted Tuple!(real, int) frexp(real value);
[snip]

Having good tuple support is great, but out parameters are great too. I'm sure 
that there are plenty of cases where using out parameters is actually far 
cleaner than using tuples, since you don't have multiple return values to deal 
with. So, better enabling tuples is great, but I don't think that we're 
necessarily moving in a good direction if we're trying to eliminate out 
parameters in favor of tuples.

- Jonathan M Davis


More information about the Digitalmars-d mailing list