commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Todd Jonker <>
Subject [Jelly] Towards Functional programming in Jelly scripts
Date Thu, 12 Dec 2002 22:09:44 GMT
Hey Jellyfolk,

I'm trying to write some Jelly tags specific to a custom component
framework.  In doing so, I realized that it would be extremely helpful to be
able to write functional tags.  In effect, I'd like Jelly to be able to
support a functional programming paradigm in addition to its current
procedural paradigm.

In short, I suggest that and Tag.doTag() both be modified to
return Object.  In other words, every tag becomes an expression that can
evaluate to a single value.  Those tags for which this isn't meaningful can
simply return null.

People familiar with Scheme or Lisp will immediately recognize what I'm
looking for and why: it will enable even easier scripting with more flexible
evaluation models.

Let me explain with a concrete example.  I want to extend JellySwing to have
an expression language that can perform Action enabling, eg:

  <instanceof value="${something}" class="MyClass" />
  <isNotNull value="${another}/>
  <core:invoke method="isReady" on="${another}"/>

The value of this script would be a Boolean.  Functional tags like these
would also be of obvious utility in JellyUnit, since this can express more
things than Jexl (as far as I can tell).  It can also be transparently
extended by any tag library without relying on variable-naming conventions.

The problem I've run into is that the only way to get a value out of a
script is via the JellyContext, by defining a variable name and making sure
my tag sticks the result in the right place.  But it order to get this model
to interact with existing logical and expression tags, the "result" variable
has to be scattered all over the file.

(Harking back to grad school, one observes that the functional model can
cleanly express the procedural model, whereas the opposite is not true.)

Perhaps there's a way to get this kind of functionality from the existing
APIs, but I've searched all over and can't see how to do it.

I realize that this API extension would involve adding lots of "return
null"s to existing tags and scripts, but it'll be MUCH easier to do this now
while Jelly's still in Beta.  And I believe the added power and
expressiveness are well worth the effort.  Of course I volunteer to help
make the transition if its implemented.

I'd love to hear feedback from James and the other users.


I look for what needs to be done.... After all, that's how the universe
designs itself. -R. Buckminster Fuller, engineer, designer, and architect

View raw message