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

Re: Re: Incrementing a Global variable

Subject: Re: Re: Incrementing a Global variable
From: David Carlisle <davidc@xxxxxxxxx>
Date: Thu, 28 Aug 2003 13:39:28 +0100
kind of variable
> Would it not be nice if both kind of variables are
> available -- the present kind ( <xsl:variable ), and a
> second kind of variable (e.g. xsl:variable2 ) which
> can increment. It will be the programmer's
> responsibility to use xsl:variable (non-incrementable)
> or xsl:variable2(incrementable)..

That wouldn't be nice at all, it would totally change the
way XSLT works. XSLT templates may be evaluated in any order,
variable values may either be stored or re-calculated from the
expression on each use, code may be re-arranged and optimised
by the compiler. All of these things require that code is side effect
free.

If you have a function f(x) and and expression

f(x) + f(x)

it may be optimised to 2 * f(x) which means you only have to calculate
the function once.

However you can't do that if there is a possibility of the "function"
doing something strange like incrementing teh value of some second
variable y as in the first case y goes up by 2 and in the second it goes
up by 1.

> If somebody wishes to produce a side-effect free
> program, he/she can use xsl:variable (which will
> facilitate that objective) ; if somebody wishes to use
> a incrementable variable , he/she can use the other
> one ..

Why use a functional language if you don't want to program in a
functional style. There are plenty of non functional languages to choose
from. 

David

________________________________________________________________________
This e-mail has been scanned for all viruses by Star Internet. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________

 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.