6 ms·
Thanks. God, I HATE operator overloading. I didn't even realize Scala had it, until a few months ago when somebody was doing a demo that involved some SBT. I
by Roboprog 10y ago
Thanks. God, I HATE operator overloading.
I didn't even realize Scala had it, until a few months ago when somebody was doing a demo that involved some SBT. It was quite frightening. (Did we learn NOTHING from the C++ debacle???)
Come to think of it, I've come to dislike "operators" in general (as opposed to function calls). Memorize these operator precedence rules? No thanks, just do the inside parens first, now you're trained.
C might be a good step up from assembler (though it, and its spawn need to go away as app dev languages), but I think Lisp got this aspect (no special, jacked up, operator syntax) right, in a "less is more" kind of way.
- deleted 10y ago[deleted]
- rvense 10y agoI've used a Scala S3 library that overloaded + to mean upload.
- whateveracct 10y agoScala doesn't have operator overloading technically. It had two orthogonal language features that give rise to operators: 1. Methods can use symbols 2. Single-arg methods can be called infix Scala doesn't have operator precedence rules. All operators (infix methods really) are left associative unless they end in a colon in which case they are right associative. Examples 2 + 1 Is 2.+(1) 2 :: 1 :: Nil Is Nil.::(1).::(2) The colon thing is the sort of thing that on paper seems hacky but in practice Just Works and is seldom used. But when you do use it it really helps a lot.
- cottonseed 10y ago> Scala doesn't have operator precedence rules. That's not true. The operator precedence is determined by the first character of the operator: (all letters) | ^ & < > = ! : + - * / % (all other special characters) Precedence is different than associativity.