riff icon indicating copy to clipboard operation
riff copied to clipboard

Overload infix operators for table operations

Open darrylabbate opened this issue 2 years ago • 0 comments

Set operations:

  • &: intersection
  • |: union
  • ^: symmetric difference
  • -: difference

List 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 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.

darrylabbate avatar Dec 03 '22 06:12 darrylabbate