Nullary and Nilary Methods
In traditional Scala, the “nullary” def f: Int
and “nilary” def g(): Int
function definitions are treated somewhat interchangeably — in particular, you can call either g
or g()
, and it does exactly the same thing.
That’s long been seen as an odd little language wart — there’s no especially good reason for it. (The usual guess I’ve heard is that it was introduced so that you could call zero-parameter Java functions without the empty parens.) Folks have long talked about removing it from the language, and Dotty does just that.
In-between, we need a deprecation period of adjustment, so the plan is to do that in 2.14. This excellent post goes into the details of what that is likely to entail, with a bunch of the nuances and things that need to change, and some proposals. It’s well worth reading if you are interested in the fine-grained details of the language, and how things are likely to evolve over the next two years.