[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Variables and constants

Subject: Re: Variables and constants
From: David Carlisle <davidc@xxxxxxxxx>
Date: Fri, 25 Feb 2000 13:42:10 GMT
constants impossible
> 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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.