XQuery is designed as a functional language. One of the design principles of a functional language is that there should not be side effects. One way of insuring no side effects is to not let variables change their values. You never "set" a variable, you bind a value to it that never changes thereafter.
So that means you can't modify a variable through a reference because you can't modify variables. You can in fact mutate variables with xdmp:set. But that's a MarkLogic extension that is not part of XQuery proper. There are uses for xdmp:set, but you should always think twice before using it. Inducing side effects in a side-effect free language is definitely a sharp tool. I would recommend returning an XML fragment with all the values you want your function to produce. On Sep 15, 2011, at 2:45 PM, Tim Meagher wrote: > Hi Folks, > > I am calling a function that returns a value but I also want the function to > set a status as well. I'm wondering what is the best way to pass by > reference? I can return an xml structure that contains the return value and > a status, but I'm also wondering about just using xdmp:set() to set a global > variable in a function. > > Thanks! > > Tim Meagher > > > _______________________________________________ > General mailing list > [email protected] > http://developer.marklogic.com/mailman/listinfo/general --- Ron Hitchens {mailto:[email protected]} Ronsoft Technologies +44 7879 358 212 (voice) http://www.ronsoft.com +1 707 924 3878 (fax) Bit Twiddling At Its Finest "No amount of belief establishes any fact." -Unknown _______________________________________________ General mailing list [email protected] http://developer.marklogic.com/mailman/listinfo/general
