Re:Eclipse launches new language to cut down Java boilerplat...
by DanielRibeiro on Friday November 04, 2011 @07:23PM
(#3198165)
Well, Ruby does go beyond this: optional parenthesis with or without arguments. Of course, no public instance variables, like Smalltalk and Scala, makes this possible.
Re:Eclipse launches new language to cut down Java boilerplat...
by maximusprime on Friday November 04, 2011 @07:56PM
(#3198264)
IMHO, it's less readable, and more ambiguous. Is it a variable or a function? Who knows!
Re:Eclipse launches new language to cut down Java boilerplat...
by eropple on Friday November 04, 2011 @11:10PM
(#3198768)
This 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.
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.