Tristan Zajonc (2013-10-28T21:46:03.000Z)
domenic at domenicdenicola.com (2013-11-03T22:01:52.080Z)
On Mon, Oct 28, 2013 at 8:14 AM, Brendan Eich <brendan at mozilla.com> wrote: > Do you mean "what's the motivation for not applying operators to mutable > objects too?" Yes. My question was why not mutable objects too? I definitely agree with the overall motivation. > Mutable objects may want certain operators for convenience, but for > mutable objects in JS, === must be reference (not transient value) > identity, and == would be pretty bug-inducing if transient value comparing. > Same comment for < and <=. Having === be reference equality is fine if that's a hard JS requirement. For a matrix API, there is some flexibility on comparison operators, but transient value comparison returning a single boolean is the most natural, other issues aside. I'm not sure I fully understand the bug you're worried about though. > What punctuators or (non-ASCII?) lexemes would you want for these > operators? I'd want every operator prefixed by something (dot, tilde, colon). You'd call these dot-operators, colon-operators, or extended-operators. One can go round-and-round on whether all these are necessary, but for matrices strictly separating objectwise/algebraic operators from elementwise/broadcasting operators has many advantages. The Julia and Mata languages have both adopted this approach. In this scheme, matrix + 1 is an error (they are not conformable for addition) and matrix .+ 1 is a matrix. Combining these tends to lead to bugs. These details would be up to the library though. > I'm not proposing syntactically novel operator extension. That is hard in > a C-like language, but doable with enough work. It would be a separate > proposal on top. Complete flexibility is not necessary in the technical computing domain. Plenty of people have proposed more operators, but most are speculative and there's definitely a valid concern of introducing too many esoteric symbols.