Subject: Re: Variables and constants From: David Carlisle <davidc@xxxxxxxxx> Date: Fri, 25 Feb 2000 13:42:10 GMT |
> Clearly this was an intentional design decision, but it makes it impossible > to do any kind of simplistic calculation (e.g. totalling a shopping cart > that has price and quantity information for each item) without resorting to > recursion But `resorting to recursion' isn't so bad and is no worse than `resorting to a loop'. A loop being just a special case of recursion. Having side effect free semantics makes programs far easier to understand, and (in principle) far easier for a system to re-order or parallelise. Consider an expression such as f(x) + f(y) If + is commutative then either f(x) or f(y) may be evaluated first, or on a suitable architechture, they may be evaluated at the same time. But if functions can have side effects, so evaluating f(x) can change the value of y then re-ordering is impossible and the semantics of the expression and thus the whole program are far harder to understand due to hidden dependencies. This is why functional programming style generally is a GoodThing. I think the reasoning behind using this style for styling langages is that if there is no global state then if you jump to page 1001 you can start to render that page immediately without having to process the entire document in order to find the values of all global variables. Due to the way xslt evolved this particular reason probaly does not apply anymore as the power of the xpath queries mean that you are more or less obliged to have the whole document in memory anyway. But still, you are not obliged to actually process templates for nodes earlier in the document unless _explictly_ accessed via a select atribute. David XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Variables and constants, John Lam | Thread | Re: Variables and constants, John E. Simpson |
Variables and constants, John Lam | Date | RE: Variables and constants, Kay Michael |
Month |