|
Because the table content is mutable .. if you change the table you change the “value" of the tuple. Consider the OP request: memoization. The tuple repesents the value of a set of function arguments, as a key in a lookup table, while the table value for that key is the return result from the memoized function. If one of those arguments is a table, and the table value changes (which can happen at any time in any place in the Lua code), then memoization breaks (badly). It also makes the entire table lookup problematic. What happens when the tuple changes to become equal to another, both of which are already in the memoization lookup table? Tuples are not inherently immutable in the same way that (say) the number 10 is, but many languages have adopted this convention to provide the kind of determinism needed for tasks like memoization. You can think of them as an aggregate constant. —Tim |