riff-lang / riff

The Riff programming language
https://riff.cx
BSD Zero Clause License
23 stars 1 forks source link

Overload infix operators for table operations #42

Open darrylabbate opened 1 year ago

darrylabbate commented 1 year ago

Set operations:

List operations:

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.