4 ms·
It's pandering to hipsters. Parenthesis are just to obvious.
by maximusprime 15y ago
It's pandering to hipsters. Parenthesis are just to obvious.
- nolok 15y agoOptional parenthesis if no argument is given was already a feature of at least pascal in the seventies. All those new "cool and innovative" languages are just rediscovering it after almost a decade of everything with C syntax. Not that it's bad or anything, it's just my OCD tingling.
- DanielRibeiro 15y agoWell, Ruby does go beyond this: optional parenthesis with or without arguments. Of course, no public instance variables, like Smalltalk and Scala, makes this possible.
- maximusprime 15y agoIMHO, it's less readable, and more ambiguous. Is it a variable or a function? Who knows!
- eropple 15y agoThis is actually half of the value of it. It allows you to easily change the implementation without breaking the public semantics. Generally speaking, the first-pass practice in Scala is to use public fields and to make them vals (final/C# readonly). Where you need to provide mutability, you use a var. But due to C#-esque properties, you can go from var x = 1 to (not great code, but illustrative of the point) private var _x: Int = 1 def x: Int = _x def x_= (value: Int) = { if (value > 1337) throw new ArgumentOutOfRangeException() _x = value } The convention is to use empty parents after zero-argument functions that have side effects, much like the ! in Scheme.