creative-scala icon indicating copy to clipboard operation
creative-scala copied to clipboard

question: operator style

Open eed3si9n opened this issue 6 years ago • 3 comments

https://www.creativescala.org/creative-scala.html#values-are-objects 2.2.2 Operators says:

1 + 2
// res4: Int = 3

1.+(2)
// res5: Int = 3

This second way of calling a method is known an operator style.

I've never heard of this name before. Is this "operator style" term used somewhere else? I am not sure if I'd associate dot-and-paren style more with "operator" than the infix notation, since operator precedence etc would affect infix notation more.

eed3si9n avatar Jan 07 '19 05:01 eed3si9n

So three issues here:

  1. This is a typo. The former is what I call operator style. I've pushed a fix for this.
  2. Is "operator style" a well known name? Perhaps not. Maybe infix operator is a better term.
  3. Should we even introduce this? cf #53 Probably should introduce it but perhaps not use infix operators as pervasively as they are currently used.

noelwelsh avatar Jan 07 '19 12:01 noelwelsh

  1. ok that makes sense.
  2. The term I see most is "infix operator notation" ("operator notation" works, but it includes prefix operator notation for -1), which is also the same term that's written right under it.
  3. +1. We probably should explain that operators are methods, but not use it so much.

eed3si9n avatar Jan 07 '19 13:01 eed3si9n

👍

noelwelsh avatar Jan 07 '19 20:01 noelwelsh