[xquery-talk] Global variables in XQuery
liam at w3.org
Wed Oct 4 12:40:03 PDT 2006
On Wed, Oct 04, 2006 at 05:24:58PM +0200, Massimo Franceschet wrote:
> I am confused about the behaviour of (what are called) global variables in
XQuery is a declarative functional language, and doesn't let you
change the value of a variable.
If you define my:global at the top level, and then in a function
define a variable called my:global, with
let $my:global := $my:global + 1
now you have two variables called my:global until the
end of the enclosing statement, when the new one will go
out of scope and the old one will be visible again.
The "let" part of a FLWOR always creates new variables.
Think of them as named constants if you prefer...
Liam Quin, W3C XML Activity Lead, http://www.w3.org/People/Quin/
http://www.holoweb.net/~liam/ * http://www.fromoldbooks.org/
More information about the talk