3 ms·
Putting addition and concatenation under the same operator massively backfires when you start using math libraries. All of the language semantics is thrown out
by ulucs 7y ago
Putting addition and concatenation under the same operator massively backfires when you start using math libraries. All of the language semantics is thrown out of the window when you can realistically sum or concatenate the same two elements, but the operator can only be used for one case (example: python and numpy).
For the list of examples, you can just use tuples if you want the "clean" look. There is no need to change the record semantics which is the same in almost all languages.
- gridlockd 7y ago> All of the language semantics is thrown out of the window when you can realistically sum or concatenate the same two elements, but the operator can only be used for one case (example: python and numpy). Huh? You can't realistically "concatenate" two numbers and you can't "add" two strings. You can only concatenate two strings, or a string and an (implicitly converted) number. You can only add two numbers, or the elements of two number arrays (or matrices). Plus isn't the "sum operator" (Σ). There generally is no sum operator, there's a sum function (which works on iterables). So what's the issue? It doesn't cause problems unless you confuse types, which shouldn't happen in a statically typed language. > For the list of examples, you can just use tuples if you want the "clean" look. Is that really true though? Can I initialize an array of records with tuples that are implicitly named? > There is no need to change the record semantics which is the same in almost all languages. This is basically C/C++ syntax, which somehow manages to be less verbose than many supposedly terser languages.