-
You can declare functions/methods normally in Groovy -- the closure attached to a symbol form:
a = { |a, b| a * b }
It is very Ruby-ish which is very Smalltalk-ish =)
-
Not what I would call "normal"... coming from Python, I would expect that I can do something like
blah(a, b) {
return a * b
}
(outside of a class declaration), which is illegal. Like I already pointed out in my post, closures make up for this. I guess that syntax is not too bad, but I don't think it's very intuitive either...
-
We'll probably come up with a function-outside-of-a-class declaration syntax at some point.
Up to now declaring just a script or declaring a class with a main() method has worked fine.
-
groovy sounds really cool.
Possibly I really like it because it seem like a {}-based ruby dialect ;).
And real closures rox.
Adding function declaration sounds needed to me, cause there are times I don't need a closure and I don't want to write a whole class/mixin for it.
BTW thanks for groovy!
-
I also really like Groovy, but as a novice Java programmer, I found http://www.judoscript.com/index.html to be more useful for the projects I was doing. It has some nice data structures built in which make it very easy to manipulate data without having to worry about all the details. No, it doesn't try to emulate Python or Ruby as much as Groovy does, but for someone who is not a Lisp expert, Judoscript was easier to grasp.
Just a thought,
Michael