Finally got my example posted to my blog here - http://
www.warneronstine.com/blog/articles/2007/04/27/my-groovy-hom-take-2
I ended up using closures that get curried in the HOM object that
then get passed to the findAll method, but of course you could even
go so far as to make that part more flexible too, depending on the
operation.
One of the things that I like about this approach is that you can
nest messages like this:
claimants.where.retired().unless.someOtherCondition()...
And of course this could go on, but the fact that a collection is
returned means that you can keep calling your special methods on the
returned list and it will keep returning HOM objects, which is
definitely not something you can do with the normal closure, you
would end up with nested ifs, thens, etc.
-warner
On Mar 27, 2007, at 3:08 PM, Warner Onstine wrote:
Hi all,
James threw down the gauntlet yesterday with respect to doing this
in Groovy. I know it can be done, and I plan on working on this
this weekend just for fun. Here's the challenge:
http://legacyofthemob.se/istari/2006/10/08/higher-order-messaging-
in-ruby/
I think that this would be a fun exercise (for those of us inclined
to do so and flex our coding muscles so to speak). Pick a language
(Scala, Haskell, Erlang, Groovy, Smalltalk, Objective-C, Lisp,
anyone up for Dylan?, etc.) and then post your findings either
here, on the wiki (if we get enough), or your blog. And I'm sure
that Bill will figure out a way to do this in Icon ;-).
BTW - I feel that it is this kind of language feature that makes it
easier to write an Internal DSL in a given language than on top of
something like Java.
-warner
Warner Onstine - Programmer/Author
New book! Tapestry 101 available at http://sourcebeat.com/books/
tapestrylive.html
[EMAIL PROTECTED]
http://warneronstine.com/blog
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
Warner Onstine - Programmer/Author
New book! Tapestry 101 available at http://sourcebeat.com/books/
tapestrylive.html
[EMAIL PROTECTED]
http://warneronstine.com/blog
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]