[xquery-talk] Setting global variables
rpbourret at rpbourret.com
Wed Oct 31 12:26:01 PST 2007
Michael Kay wrote:
> Sounds like you're having difficulty getting procedural programming out of
> your mindset... It's this concept of "later" that gives it away. In
> functional programming, there is no time axis, no concept of "earlier" or
Interesting point. I hadn't thought about this.
Is the whole point of functional programming to allow better
optimization by the processor / compiler? Or are there other advantages
> The answer is to initialize the global variable to the subset of the
> document that's needed, from within its own initializer.
As I mentioned to John, I can't do this because the document name can
change. If I could pass the document name from a point external to the
library, this would solve my problem. (I suppose I should check the
Saxon documentation and see if this is possible...)
> Incidentally, the problem of passing parameters through functions that don't
> actually look at them directly sounds like a request for something like XSLT
> 2.0's tunnel parameters.
> It looks as if XQuery is going to be extended to turn it into a procedural
> language through "scripting extensions". As far as I'm concerned, that's a
> great shame - being forced to learn to use functional programming has made
> me a much better programmer.
I've had to jump through a slightly different set of hoops, but it all
feels about the same as performing structured programming. By
"structured programming", I mean breaking your application into many
small functions and only passing to each function the information it
needs. This as opposed to 70s-style spaghetti code, with lots of global
variables and GOTOs. That was a big difference for me and led to much
Of course, here I am asking for global variables :)
More information about the talk