cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Glen Ezkovich <>
Subject Re: xml languages
Date Tue, 25 Jan 2005 04:50:50 GMT

On Jan 24, 2005, at 3:10 PM, Daniel Fagerstrom wrote:

> Vadim Gritsenko wrote:
>> Daniel Fagerstrom wrote:
>>> Ok, that explains the behaviour, the question is what we should do 
>>> about the, admitingly, weird behaviour.
>> How it is weird - it's same as in xslt.
> Not exactly, while xsl:variable is like a final declaration in Java, 
> jx:set is an asignment and can be used for e.g. counting things in a 
> forEach. The "weird" part is that you can't define a global variable 
> and use it as a counter in a sequence of loops as it will be redifined 
> in the current context if it does not exist there. See Eric Burghard's 
> example earlier in this thread.
>>> One possibilty would be to decide that we want JXTG to be more like 
>>> a functional language.
>> +1
>>> In that case we should deprecate jx:set and introduce a jx:let 
>>> instead that just gives a local name for an expression and that 
>>> gives an exception if you try to set the "variable" to a new value.
>> Not sure this is necessary.
>>> I think I would prefer this behaviour as I would prefer having a 
>>> template language without side effects.
>> +100
>>> Another possibility is to let set asign the value to the first 
>>> variable binding with the same name that it finds when the stack is 
>>> searched,
>> -1. Don't think this is a possibility; as noted above, templates 
>> should be side effect free.
> Glad that you agree :) Eric and Leszek are not convinced at all and 
> want real assignment.
> I would also prefer complete freeness of side effects, but that would 
> require us to write an own expression language as both Jexl and JXPath 
> allows for calling put methods etc.

While this is true these are the expression languages used within the 
template language. The problem is that there is noway in Java to 
prevent a method invocation having side effects. If we were to use 
reflection to check whether a method returned a value we still couldn't 
be sure that it did not have any side effects. If you want to prevent 
side effects you would need to allow JXTG to only accept read only maps 
of strings and other maps. I'm pretty sure this would cause a riot.

All we can insure is that nothing within the jx namespace has any side 

> There is the same problem with extension functions in XSLT, but of 
> some reason people seem much more interested in using side effects in 
> JXTG than in XSLT.

Side effects are easy, even though evil. There is nothing you can do 
with side effects that you can't do without them. It's some times just 
simpler. Recursion fries minds. Maybe the reason people are interested 
in side effects in JXTG is that they don't like the side effect free 
nature of XSLT.

> Maybe JXTG lacks some functionallity needed for important use cases or 
> maybe it is still another instance of the hammer anti pattern ;)

The simple fact is JXTG is not appropriate for every conceivable use 
case. So please don't bang on it too much. ;-)

> /Daniel

Glen Ezkovich
HardBop Consulting
glen at

A Proverb for Paranoids:
"If they can get you asking the wrong questions, they don't have to 
worry about answers."
- Thomas Pynchon Gravity's Rainbow

View raw message