Allow function definitions to omit parentheses if no parameters

I don't like the analogy to omitting the -> Void on a function return. Writing -> Void in a function definition implies to users, particularly those that are less experienced, that the function “returns something”. Since the function isn't marked @discardableResult, it's easy to misunderstand and think that the return is meaningful, or that you should write _ = f(…), etc. Omitting the return here makes the definition easier to understand, because you can also omit the code handling the return value at the call site.

The opposite is true of omitting the parentheses in function definitions, which could be misunderstood as meaning they can be omitted from call sites. This wouldn't be an unusual interpretation because it has precedent in other languages, where computed properties are just function calls where you can omit the parentheses at the call site. So I don't see how the very minor improvement in brevity is justified here.

4 Likes