全局变量?局部变量?

来源:互联网 发布:java开发整个流程 编辑:程序博客网 时间:2024/05/17 02:03
这两天碰到一个问题。关于XQuery中变量的作用域问题。
define function getResult() as node{
let $k:=$g
return $k
}

let $g:=(1,2)
rturn getResult()

$g在函数getResult中到底是否有效呢?
规范上好像也没明确说明。还是我没看明白?

[2005年11月29日]
The static context for a function body includes all functions that are declared or imported anywhere in the Prolog, but it includes only those variables and namespaces that are declared or imported earlier in the Prolog than the function that is being defined.
 这句应该说明上面的$g不应该是全局的。
原创粉丝点击