Reconsider the old import syntax #17876
Replies: 1 comment
-
I suggest we "normalize" backticks. I prefer it for test method names which are never referenced in code.
I remember I contributed something about backticked asterisk (and say that ten times fast) to Scala 2. Was that for patterns or imports? Maybe it was regular asterisk but backticked underscore, since Scala 2 supports underscore as a name for (misconceived) reasons of compatibility. In any case, this ship of syntax has sailed. Another angle is that Although I liked "underscore everywhere" in principle, in practice the new syntax is tractable and doesn't generate tickets. |
Beta Was this translation helpful? Give feedback.
-
The new import syntax looks familiar and is friendly to newcomer from other language, but it seems not so suitable for Scala.
The import syntax should be distinct from the legitimate identifier as possible to make it clear. In Scala, both
*
andas
are legitimate identifiers while in other language such as Rust and Python they are not.`
can be used for disambiguation, but it should not be encouraged outside of test code, and the new import syntax forces the usage of`
when just importing*
, which is useful in some calculation-specific codes.The soft keyword
as
was dropped in given syntax and pattern binding and is only used in import syntax currently, which seems to violate the design philosophy of Scala.The old import syntax looks perfect, since neither
_
nor=>
is treated as a legitimate identifier so they can be easily recognized in the long import list. So the old import syntax may be a better choice than the new one?Beta Was this translation helpful? Give feedback.
All reactions