Tuples citizenship

deadalnix deadalnix at gmail.com
Fri Mar 2 01:36:10 PST 2012


Le 02/03/2012 03:06, bearophile a écrit :
> Jonathan M Davis:
>
>> Yes, but chaining functions is the issue. It doesn't work well with tuples
>> unless the function you're passing the result to wants the tuple. If all it
>> wants is one piece of the tuple, then that doesn't work well at all. You're
>> forced to assign the tuple to something else and then call then function
>> rather than chain calls.
>
> In the years I have used a mountain of tuples in Python, but I barely perceive that problem, so I think it's not so bad.
>
>
>> int exp;
>> auto result = frexp(value, exp);
>>
>> vs
>>
>> auto tup = frexp(value);
>> result = tup[0];
>> exp = tup[1];
>
> I have assumed to use a sane tuple unpacking syntax. So the second part of your comparison is:
>
> immutable (result, exp) = frexp(value);
>

You got it right. +1


More information about the Digitalmars-d mailing list