Possible Duplicate:
Why use tuples instead of objects?
Suppose you are using a programming language that allows you to return multiple values from functions, e.g., x, y = f(a, b)
.
It seems to me like using a struct/object that has named attributes is generally better than using a tuple, for readability. For example, I think p.x
is more readable than p[0]
.
A common use of tuples is for key-value pairs in associative arrays. But to me, x.key
and x.value
seems more clear than x[0]
and x[1]
.
Is the reason for tuples instead of named types just convenience? This makes me think the syntactic overhead for declaring new types is too high in most programming languages.