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

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





------- Comment #29 from simeon@us.ibm.com  2006-11-02 17:27 -------
Here is (yet) another proposal trying to break the Gordian knot on bug
1705.  This is a (preliminary) proposal currently being considered by
the XML Query working group at its face to face meeting. Any early
feedback on it would be greatly appreciated.

- Jerome


Overview
--------

The proposal defines circularity between modules based on whether
variables depend on variables or functions in another module.

This notion outlaws the specific example that was posted in comment #1
for that bug. It allows to order modules based on how variables in one
module depend on variables in another module.

Details follows.


Changes to XQuery 1.0 book
--------------------------

(1) Make 'depends on a variable or function' a definition in XQuery
1.0.

(2) Define formally a notion of module dependency as follows.

<<
A module M1 depends on a module M2 if a variable or function in M1
depends on a variable or function in a module M2, where M1 and M2 are
distinct modules.
>>

NOTE: Based on that definition M1 never depends on M1.

(3) Add a restriction to module import:

<<
If a module depends on itself by any combination of transitive
dependencies, a static error is raised.
>>


Changes to XQuery FS book
-------------------------

Note this proposal also takes bug #1743 into account. What follows are
only the main rules, not all specific changes yet.

*** Add the new judgments:

  Module1 ... Modulen reordered as Module1' ... Modulen'

Which takes a set of Modules, and reorders them based on the absence
of circularity. The order is such that variables in a module Modulei
only depends on variables defined in Module1...Modulei-1.

  statEnv1 |- PrologDecls gather function signatures statEnv2

Which extends the static environment with a set of function signatures.



*** In Section 5.2 Module Declaration, replace the existing SCP rule by:

  AnyURI  is target namespace of modules Module1 ... Modulen
  Module1 ... Modulen reordered to Module1' ... Modulen' (***)
  Module1' = module namespace NCName1 = URILiteral; PrologDeclList1
  ...
  Modulen' = module namespace NCName1 = URILiteral; PrologDeclListn
  statEnvDefault |- PrologDecls gather function signatures statEnv0
  statEnv0 ; AnyURI |- declare namespace NCName = URILiteral;
    PrologDeclList1 =>stat statEnv1 with PrologDeclList1'
   ...
  statEnvn-1 ; AnyURI |- declare namespace NCName = URILiteral;
    PrologDeclList1 =>stat statEnvn with PrologDeclList1'
  ------------------------------------------------------------------
  AnyURI =>module_statEnv statEnvn0

(***) Always exists because there isn't circularity

The main idea is that we can alway order the modules so they do not
depend on eeach other, getting rid of circularity and making sure the
simpler version of SCP which goes through modules in order can
terminate.

NOTE: There should be some changes to the judgment:
  statEnv0 ; AnyURI |- declare namespace NCName = URILiteral;
  PrologDeclList1 =>stat statEnvn with PrologDeclList1' so that it
  passes only the relevant part of the static environment between
  modules.


Changes to Section 5.11 Module Import
-------------------------------------

*** In SCP, replace the rule:

  AnyURI1 =>module_statEnv statEnv1
  ...
  AnyURI1 =>module_statEnv statEnvn
  statEnv extended with static environment statEnv1
              yields statEnv1' for uri AnyURI
  ...
  statEnvn-1 extended with static environment statEnvn
              yields statEnvn' for uri AnyURI
  ----------------------------------------------------------------
  statEnv |-  import module AnyURI1 LocationHints? =>stat statEnvn

By:

  AnyURI =>module_statEnv statEnv
  statEnv extended with static environment statEnv1
              yields statEnv1' for uri AnyURI
  ...
  statEnvn-1 extended with static environment statEnvn
              yields statEnvn' for uri AnyURI
  ----------------------------------------------------------------
  statEnv |-  import module AnyURI LocationHints? =>stat statEnvn


Changes to Section 5.14 Variable Declaration
--------------------------------------------

No changes.

Changes to Section 5.15 Function Declaration
--------------------------------------------

No changes

Received on Thursday, 2 November 2006 17:27:53 UTC