On Monday, April 4, 2016 at 7:27:40 AM UTC-4, Stefan Karpinski wrote:
>
> Number does not imply or assume commutativity. The Quaternions package 
> provides a Quaternion type which is a subtype of Number. Rational, however, 
> only allows integer numerators and denominators. Since integer 
> multiplication is commutative, rational multiplication is too. But I still 
> think it best to reserve \\ with an analogous meaning to //. There are 
> already two syntaxes for integer division, which is plenty.
>

That is your opinion, however a number of other people disagree. Every 
other language I've dealt with has had a simple ASCII sequence for integer 
division, / (in C, C++, Java, Python2 with integer operands), \ (in Mumps & 
Caché Object Script), or // (Python and Lua).
(and no, typing \div<tab> in the REPL and something else in an editor [as 
well as having to customize one's editor] just to get a Unicode ÷ 
character, is not really that useful)

About \\ in particular, that's fine then, probably better to reserve that 
for rationals.
To me, it does seem a bit strange though that // was picked for rationals 
in Julia, something sure to cause confusion for people coming from Python 
(which seems to be a large part of people moving to Julia) or Lua, when 
integer division is used so much more frequently than rational numbers.
There are only 6 uses of // outside of rationals.jl in base (4 of those are 
in mpfr.jl), compared to 187 uses of div, and 22 uses of ÷.  (that's uses, 
not definitions, exports, documentation, although the ratios are very 
similar).
Looking at packages, it seems also that div is used frequently, and many 
times more than // for rational numbers.

What about a different two character ASCII sequence that is currently a 
syntax error?
I think /| could be used, and could be easily remembered as being integer 
division (unlike ÷), it could be described as doing a division / and 
cutting off the remainder |.

Reply via email to