21 Apr 2004 12:15
Re: Parens and Parameters
On 21 Apr 2004, at 05:46, clint@... wrote: > I see my error now. I didn't understand the reasoning for the > inconsistent > rule about optional parens until I read Chris' note about > writer.println being > a method pointer. This reminded me that the following code is legal > in groovy: > > p = writer.println > p() > > Very nice, but this feature forces the use of the "optional" parens on > calls > like writer.println(). I really don't like optional syntax, > especially when > it's not optional.You could argue the above isn't using optional syntax. // property access syntax foo.bar // method calling syntax foo.bar() So the above would still work even if () were mandatory in all cases. i.e. right now today, using property access notation will try lookup a bean property, if there's no property of that name it returns a method closure for that method (if there is a method of that name). James ------- http://radio.weblogs.com/0112098/
You could argue the above isn't using optional syntax.
// property access syntax
foo.bar
// method calling syntax
foo.bar()
So the above would still work even if () were mandatory in all cases.
i.e. right now today, using property access notation will try lookup a
bean property, if there's no property of that name it returns a method
closure for that method (if there is a method of that name).
James
-------
RSS Feed