dotty-feature-requests
dotty-feature-requests copied to clipboard
Remove ':' with explicit typing
Dotty is removing boilerplate, so I suggest remove the colon too. Examples:
Before
val name: String = "Andreu"
After
val name String = "Andreu"
Before
def someRandomMethod(name: String, age: Int, foo: Option[String]) = "Andreu"
After
def someRandomMethod(name String, age Int, foo Option[String]) = "Andreu"
I would prefer remove val
too, but we could start with the colon.
The use case is the awkward space for operators:
def --? : Boolean
def tpe_* : Type
becomes
def --? Boolean
def tpe_* Type
Also it properly distinguishes a regular value definition (simple name and type) from a pattern variable definition (pattern which may also be followed by a type).
The natural direction to take this is now:
val name as String = "Andreu"
Probably it would work in a pattern context but not as an expression:
val name = "Andreu" as String