Open nyuichi opened 11 years ago
+1, bot there're some issues:
operator==()
has a limitation that it won't be used in native methods. e.g. Array#indexOf() uses == internally but we couldn't overload it unless JSX provides its own implementationoperator+(number, BigInt)
? It may be a global function but JSX cannot have top level global functions@gfx
operator==
In that case, we simply prohibit users from overloading the ==
operator. We might have to disallow &&
and ||
.
operator+(number, BigInt)
The answer: you cannot implement such a method. Fortunately we only have operators which we can alternatively swap the operands or use and combine other operators to do the same thing. So you don't need to overload operators the first argument is of a primitive type.
operator+(number, BigInt)
The answer: you cannot implement such a method. Fortunately we only have operators which we can alternatively swap the operands or use and combine other operators to do the same thing. So you don't need to overload operators the first argument is of a primitive type.
I doubt if the statement hold valid when a user tries to implement cross-product of vectors using operator overloading. Any ideas?
@kazuho
In that case you should not use *
operator to do cross-product. Drfining cross
or outer
method is much better. I guess thr rule that operations breaking the commutative law must not be defined using embedded operators is a very popular convention widely adopted. When operator overloading is included in jsx, we should adopt this convention at that time.
syntax (and the convention) may subject to change, but at least about arithmetic operations, if there were overloaded operators, it would be so useful.