This goes slightly against some of the original design philosophy of the language - data types can be very freely coerced, but the operations themselves have always been consistent in the types of values they yield. This is why a separate concatenation operator exists; so that x + y will always yield a numeric result and x # y will always yield a string, regardless of whether x or y is a number or a string. As opposed to overloading + for string concatenation like many other languages.
However, I feel OK with making exceptions when both operands are tables, since the result of any of these operations would otherwise be completely useless.
Set operations:
&
: intersection|
: union^
: symmetric difference-
: differenceList operations:
+
: append (concatenate?)This goes slightly against some of the original design philosophy of the language - data types can be very freely coerced, but the operations themselves have always been consistent in the types of values they yield. This is why a separate concatenation operator exists; so that
x + y
will always yield a numeric result andx # y
will always yield a string, regardless of whetherx
ory
is a number or a string. As opposed to overloading+
for string concatenation like many other languages.However, I feel OK with making exceptions when both operands are tables, since the result of any of these operations would otherwise be completely useless.