[Bug 1705] [FS] technical: 5.2 Module Declaration: cyclical imports

http://www.w3.org/Bugs/Public/show_bug.cgi?id=1705





------- Comment #20 from simeon@us.ibm.com  2006-10-19 18:05 -------
Yes, I did think it was a serious problem with respect to the approach
currently taken for the formal semantics. Now in the process of implementing
the resolution for Bug #1704, I realized that we could process the variables at
the level of the module declaration, i.e., when the static context is built for
all the modules in the same namespace.

After implementation of Bug #1704, the rule looks as follows:

AnyURI  is target namespace of modules Module1 ... Modulen
Module1 = module namespace NCName1 = URILiteral; PrologDeclList1
...
Module1 = module namespace NCName1 = URILiteral; PrologDeclListn
dynEnv |-  URILiteral has atomic value AnyURI
statEnvDefault |- declare namespace NCName = URILiteral;
                    PrologDeclList1 =>stat statEnv1 with PrologDeclList1'
...
statEnvn-1 |-  declare namespace NCName = URILiteral;
                    PrologDeclListn =>stat statEnvn with PrologDeclListn'
--------------------------------------------------------------------------------------
AnyURI =>module_statEnv statEnvn

So I am thinking we could add some non-formally specified judgment that would
"sort" the variables in such a way that there is no forward references anymore.
If there is no circularity, that judgment should be well-defined.

That judgment could look as follows:

process variable order PrologDeclList1,...,PrologDeclListn to PrologDeclList0

this process would make sure that variables are ordered in a way that no
variable declaration is declared after it is used. It would leave function
declarations unchanged. That would essentially reflect the intent of the
corresponding sentence in XQuery:

<<
The initializing expression for a given variable must be evaluated before the
evaluation of any expression that references the variable.
>>

This idea is similar to an intuition proposed by Michael Kay.

The final rule would look as follows:

AnyURI  is target namespace of modules Module1 ... Modulen
Module1 = module namespace NCName1 = URILiteral; PrologDeclList1
...
Module1 = module namespace NCName1 = URILiteral; PrologDeclListn
dynEnv |-  URILiteral has atomic value AnyURI
process variable order PrologDeclList1,...,PrologDeclListn to PrologDeclList0
statEnvDefault |- declare namespace NCName = URILiteral;
                    PrologDeclList0 =>stat statEnv with PrologDeclList0'
--------------------------------------------------------------------------------------
AnyURI =>module_statEnv statEnv

which is not that much more complex.

I don't know if I am missing something here.
Feedback on this proposal would be greatly appreciated.

Thanks,
- Jerome

Received on Thursday, 19 October 2006 18:05:27 UTC