Tuples citizenship
renoX
renozyx at gmail.com
Fri Mar 2 05:13:51 PST 2012
On Friday, 2 March 2012 at 10:13:17 UTC, Jonathan M Davis wrote:
> If the function uses out, then you can chain the return value
> without losing
> the values which were assigned to the out arguments, but if you
> have a tuple,
> and you select one of the elements in the tuple to chain, you
> lose the others.
> The only way to get _all_ of the values in the tuple is to
> assign the tuple to
> a variable, in which case, you can't chain at all.
>
> - Jonathan M Davis
Sure, but due to D's syntax which doesn't distinguish in/out/ref
params in a function call, this is quite confusing to read: when
you read f(x,y) which is in, which is out? If D's syntax was
f(x, at y) (@ to distinguish out or ref parameter), this would be
easy to read, but this isn't the case.
At least with tuples you don't have this issue.
Not that I consider tuples always the good answer: for the common
use case where you want to return an error code and a result, the
Maybe "monad" is better..
BR,
renoX
More information about the Digitalmars-d
mailing list