title: Updating variables in XQuery - possible or not?
body: <p>I'm a little bit confused concerning variable updates in XQuery:
  On [1] it says:</p>
  
  <blockquote>
    <p>Variables can't be updated. This means you can't write something like let $x := $x+1. This rule might seem very strange if you're expecting XQuery to behave in the same way as procedural languages such as JavaScript. But XQuery isn't that kind of language, it's a declarative language and works at a higher level. There are no rules about the order in which different expressions are executed (which means that the little yellow triangle that shows the current execution point in the Stylus Studio XQuery debugger and XSLT debugger  can sometimes behave in surprising ways), and this means that constructs whose result would depend on order of execution (like variable assignment) are banned. </p>
  </blockquote>
  
  <p>I'm wondering if there is really no way to reliable update a variable? Maybe I'm just to used to those things in other languages, but I can't really imagine / believe it ;-)</p>
  
  <p>[1] <a href="http://www.stylusstudio.com/xquery_flwor.html" rel="noreferrer">http://www.stylusstudio.com/xquery_flwor.html</a>, second paragraph below the screenshots of the chapter "L is for LET"</p>
  
  <p><strong>UPDATE:</strong> 
  I have to add a question to this: Shouldn't it be possible to update an existing variable in an if statement because in this case the order of execution is clear? I guess you just aren't allowed to use something like $x = $x+1 in a loop?</p>