On Sat, Mar 15, 2014 at 6:33 PM, Joe Kington <joferking...@gmail.com> wrote: > On Sat, Mar 15, 2014 at 1:28 PM, Nathaniel Smith <n...@pobox.com> wrote: >> >> On Sat, Mar 15, 2014 at 3:41 AM, Nathaniel Smith <n...@pobox.com> wrote: >> > Hi all, >> > >> > Here's the main blocker for adding a matrix multiply operator '@' to >> > Python: >> > we need to decide what we think its precedence and associativity should >> > be. >> >> Another data point that might be useful: >> >> Matlab: same-left >> >> >> R: tight-left > > > > I was going to ask this earlier, but I was worried I was missing something > major. > > Why was "tight-left" not an option? > > > This means that if you don't use parentheses, you get: > a @ b @ c -> (a @ b) @ c > a * b @ c -> a * (b @ c) > a @ b * c -> (a @ b) * c > > > In my (very inexperienced) opinion, it seems like the most intuitive option.
Because tight-left doesn't seem to have much to recommend it over same-left, and all else being equal having fewer levels of precedence is usually considered a good thing. Unless I'm missing something. If we do decide that tight-left is best then we could certainly advocate for it. I wouldn't read too much into R's choice; they don't actually define a separate precedence level for matrix multiplication specifically. They have a single precedence level for all "special" (user-defined) operators, and matrix multiplication happens to be one of these. (Their versions of // and % are also "special", but I don't think anyone would expect // to bind more tightly than / if one were choosing precedences on a case-by-case basis.) -n -- Nathaniel J. Smith Postdoctoral researcher - Informatics - University of Edinburgh http://vorpus.org _______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion