News for hackers. Stuff that matters.
Re:Eclipse launches new language to cut down Java boilerplat... by oacgnol on Friday November 04, 2011 @06:55PM (#3198067)
That's what Scala already does: if a method does not take any args then the parentheses aren't necessary.

To quote Odersky: "This convention supports the uniform access principle which says that client code should not be affected by a decision to implement an attribute as a field or method."

It makes sense if you want to implement something that may be a field but needs to be computed.

Re:Eclipse launches new language to cut down Java boilerplat... by MichaelGG on Friday November 04, 2011 @09:08PM (#3198464)
How do you differentiate between referencing a method, and calling the method? I.e., foo.Sort(x.compare)?

I think the idea of computed fields implemented via methods is better represented via C#-style properties, although I'd prefer to be able to access their methods directly, when suitable.

Re:Eclipse launches new language to cut down Java boilerplat... by ankurdave on Friday November 04, 2011 @10:10PM (#3198621)
You'd use an underscore to form a partially applied function:

    foo.Sort(x.compare _)
And Scala's getters and setters are essentially equivalent to C#'s properties:

    class A {
        private var _x = 0
        def x = _x
        def x_=(value: Int) { _x = value }
    }

    val a = new A
    a.x = 5
    println(a.x)
Re:Eclipse launches new language to cut down Java boilerplat... by nknight on Friday November 04, 2011 @10:42PM (#3198687)
So instead of a simple, uniform rule that () invokes a function, and no-() references the function, you add yet a third syntax?

This is not an improvement, it is an unnecessary complication.

Re:Eclipse launches new language to cut down Java boilerplat... by skaalf on Saturday November 05, 2011 @12:08PM (#3200061)
That's not the same thing. You obviously use partial application only if the function takes params. And I just can't see why you'd like to pass a reference on a parameter-less function.
Re:Eclipse launches new language to cut down Java boilerplat... by nknight on Sunday November 06, 2011 @12:48AM (#3201875)
Closures don't need to take parameters to be useful, but you're missing the point.

There is a simple, unambiguous rule -- () calls, no-() references. In order to... what? save two keystrokes? -- you have added a strange corner case, and then tacked on a new bit of punctuation for partial application. Though now it seems you're adding the rule that functions without parameters can't be referenced.

This takes a simple yes-or-no rule and adds edge cases for no reason. Two keystrokes on the occasional parameterless function call is not a real savings, and you've just made it harder for someone reading the code to spot all the function calls.

This fundamentally makes no sense. Why would this be a good idea?

Re:Eclipse launches new language to cut down Java boilerplat... by skaalf on Sunday November 06, 2011 @01:47PM (#3203423)
There's no ambiguity when you're using closures. Concerning partial function application, you need a special syntax anyway (unless you consider all functions to be curried by default). You don't do that to save keystrokes, you omit parenthesis because "All services offered by a module should be available through a uniform notation, which does not betray whether they are implemented through storage or through computation."

I used scala for a while, I admit there's a whole bunch of features that can get you confused. This takes 30s to spot.