Drop the keyword func of functions

Variables are declared like

var myVariable:String?

or containing prefixes like private, fileprivate, lazy, etc.

Computed variables start the same way. So they are easily differentiated from functions.

Do functions have to have "func" at the beginning?

Example:

override func viewDidLoad() {
super.viewDidLoad()
doSomething()
}

could be written as

override viewDidLoad() {
super.viewDidLoad()
doSomething()
}

What do you think?

This is a massive breaking change without a single benefit except for not needing to type 5 characters. My personal response to this will be: -1

17 Likes

Sry TL;DNR :wink:

2 Likes

There needs to be a compelling reason for the change. Do you have anything besides β€œit saves a few characters?”

1 Like

Consider the following, under your proposed syntax:

foo(_ someClosure: () -> ()) {
    // ...
}

foo() {
    // ...
}

Is the second statement declaring a new function overload, or calling the first function with a trailing closure?

11 Likes

-1, It provides no functionality to remove the keywords.