dotty-feature-requests icon indicating copy to clipboard operation
dotty-feature-requests copied to clipboard

Remove ':' with explicit typing

Open AndreuCodina opened this issue 5 years ago • 2 comments

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.

AndreuCodina avatar Jan 15 '20 17:01 AndreuCodina

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).

som-snytt avatar Jun 21 '20 22:06 som-snytt

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

som-snytt avatar Sep 25 '20 05:09 som-snytt