This is where your argument falls down. New users will not add @infix
in front of everything.
-
They will not be able to add
infix
in front of every standard library method, -
nor will they be able to add
infix
in front of any third party libraries. -
PRs to add infix to the standard library for random methods like
Iterable#map
will probably be argued over and rejected. -
PRs to add infix to third party libraries will be met with confusion (“Why would you can to call
.toFooBar(qux: Qux)
infix???”). PRs to add infix to the Java standard library are impossible. -
They will not know to add
infix
in front of the methods they define themselves. It’s not like there’s a wealth of blog posts and books talking about using that keyword
What will end up happening is that the new users will just not call any methods infix unless the library author explicitly wanted to be called infix, and would just not define any of their own methods that can be called infix until they become more advanced users and learn about the feature from more advanced sources
To me that is the intended outcome. Not no infix methods, but only infix methods that the definition author intended to be infix, where the definition author knows what they are doing
Well that just tells me you don’t use ranges. When you want to use something a lot, you call it
P
orT
or somesuch. I think it’s a great insight that it’s fine to make the critical common stuff super-easy to use.
If one uses a lot of ranges, one knows what
to
anduntil
mean, and one doesn’t want it longer. (It could be different, but not longer.)
If you’re using them a lot, it’s fine to add your own helper methods. I myself have several such helper libraries, including os-lib
and requests-scala
, that are simply wrappers around parts of the standard library that I use a lot and want to be shorter.
If such helper libs became popular, that would be convincing to me that is resonates broadly with the community. Otherwise, “one person does things that way and likes it” doesn’t really help make a judgement of a feature’s net pros/cons across the language community
Forcing infix
is an explicit choice that restricts what people do. Obviously the people who enjoy the thing being restricted won’t like it. The bet is that there is a large pool of people who would appreciate the limits, or would appreciate the additional uniformity that the restrictions enforce.
It’s fundamentally a bet between Ruby-like or Python-like syntax. It’s a bet on Javascript v.s. Coffeescript. There are plenty of people who like Ruby (and liked Coffeescript! Remember when it was the default for Ruby on Rails???) but I think the market has spoken which one is more adoptable, and Scala is clearly trying to move in the Python-like direction for its surface syntax