2 May 2005 14:16
With (continued, and the use of 'delegate')
Hello,
I ceize the opportunity of the "with" keyword debate to make a few remarks:
1) Groovy's pretty powerful and self-evolutive
2) There's some uses for the "delegate" notion in closures
So, why do I say that Groovy is pretty powerful and self-evolutive?
Because of its Metaobject protocol facilities (property setter/getter
and invoke method interception) and its extensibility with regard to
adding new methods on standard Java objects (ie. Groovy JDK).
Following the idea of the "with" keyword, and taking advantage of
Groovy's power and extensibility, Jeremy implemented a new "identity"
method on Object -- thus available to any object. In CVS Head, you can
do something like that:
foo[i].bar().film.identity { f ->
f.name = "Lavender Hill Mob"
f.year = 1951
}
You've got a complex expression, and without having to repeat each
time that long expression or assigning it to some temporary variable,
you can use a closure to assign some values to the object's
properties.
Jeremy rocks
Though John Rose and James seems to want to abandon the "delegate" of
(Continue reading)
RSS Feed