RE: focus over function calls

> Section 3.1.4 of the new main XQuery specification says:
> 
>     A function does not inherit a focus (context item, context
>     position, and context size) from the environment of the function
>     call. During evaluation of a function body, the focus is 
> undefined,
>     except where it is defined by the action of some expression inside
>     the function body. Use of an expression that depends on the focus
>     when the focus is undefined results in a dynamic error.
> 
> Why a dynamic error?  It seems like this could and should be a static
> error:  An expression that depends on the focus is defined 
> iff the expression appears inside a function definition but 
> not in a predicate. And there are only a fixed predefined set 
> of "functions" that depend on the focus, so we can easily 
> detect this error statically.
> 

Interesting. Yes, many implementations will be able to detect this error
statically. But in the formal semantics we currently have no rules that tell
us which expressions depend on the context item and which don't. The
analysis is not trivial, for example string() depends on the context item,
and I don't think we should try and prescribe it. In cases like this I think
we should allow implementations to raise a static error, but not require it.

Michael Kay

Received on Sunday, 20 October 2002 14:27:53 UTC