- About Scala
- In the Enterprise
- Scala Community
- Language Research
- In the Press
- The Scala Team
- Scala's Prehistory
- Contact Us
- Learning Scala
- Tour of Scala
- Scala API
- Setup & Getting Started
- Programming Guides
- Other Guides
- Code Examples
- Scala Developers
Too many uses for "=>" in Scala
There's been alot of discussion of late of all the various uses of "_" in
Scala. I certainly could live without most of them, as they seem largely for
expository purposes about very small programs/slideware.
What about the "=>" operator.
It is used for defining functions, by-name parameters, case clauses, and, my
least favorite, self aliases. Probably there are more places that I haven't
To me it's totally clear that aliases should use the keyword "alias".
By-name parameters should use the keyword "by name". The others are fine as
they occur far more often.
I simply fail to see the rationale for not having a keyword for
self-aliases. I just don't see any analogy at all to functions for this
usage, and I really don't see this construct arising so often that it needs
an operator for code clarity/brevity reasons.
I advocate controlled and slow change for Scala at this point. I.e., for
Scala to evolve in a way which strongly respects compatibility, so while I
want these changes, I would add a keyword, deprecate the prior usage, but
leave it supported for a LONG time, like until the 3rd edition of the Scala
book comes out.