[XQuery] Early Lall Call comment on Prolog syntax

I posted a comment to the XQuery WG last year that was moved to become a
last call. The mail is located at
http://lists.w3.org/Archives/Member/w3c-xml-query-wg/2003Oct/0046.html 

 

I was asked to forward it to the public list, so here is the content of
the mail for public archiving and replies:

 

This mail proposes an improvement to the query prolog syntax to address
the ordering issues that several of my implementers have raised and that
I have reported previously. Currently the grammar allows a function
declaration before the default collation declaration, and a schema
import can syntactically occur after a function declaration that refers
to the type name imported. Since this arbitrary ordering complicates the
prolog processing and the specification of such, we would like to
propose a certain order in the prolog. We first have the version, then a
group of context setters, then a group of namespace declarations and
imports and then the variable and function declarations.
 
I propose two syntactic varieties that distinguish for variable and
function declarations and present the choice between two semantic
varieties for the variable reference case. Note that I assume that we
continue to allow a function declaration to refer to a function that is
syntactically declared later at the same module level.
 
Syntax A:
=========
 
Prolog ::= (Version Separator)?
           (Setter Separator)*
           (Decl Separator)*
           (VarDecl Separator)*
           (FunctionDecl Separator)*
 
Setter ::= XMLSpaceDecl     ; each setter occurs at most once
         | DefaultCollationDecl
         | BaseURIDecl
         | ValidationDecl
 
Decl   ::= NamespaceDecl    ; each decl appears any number of times
         | DefaultNamespaceDecl
         | SchemaImport
         | ModuleImport
 
Syntax B:
=========
 
Prolog ::= (Version Separator)?
           (Setter Separator)*
           (Decl Separator)*
           (VFDecl Separator)*
 
Setter ::= XMLSpaceDecl     ; each setter occurs at most once
         | DefaultCollationDecl
         | BaseURIDecl
         | ValidationDecl
 
Decl   ::= NamespaceDecl    ; each decl appears any number of times
         | DefaultNamespaceDecl
         | SchemaImport
         | ModuleImport
 
VFDecl ::= VarDecl | FunctionDecl
 
Semantic Interpretation I:
--------------------------
 
Example 1:
 
declare variable $a as xs:integer { $b + 42 } 
declare variable $b as xs:integer { 0 }
 
Example 2 (only for Syntax B):
 
declare function foo($x as xs:integer) as xs:integer {
  $x + $const
}
declare variable $const as xs:integer
 
Both examples work without error.
 
Semantic Interpretation II:
---------------------------
Neither of the two examples works. The declaration of $a in Example 1
would raise an error about not having $b declared yet, and the function
body in example 2 would raise an error that the $const has not been
declared yet.
 
Which would you prefer?
A.I., A.II., B.I., or B.II?
 
We have a slight preference of A over B and interpretation II over I,
but can live with the others.
 
Best regards
Michael

 

Received on Thursday, 22 January 2004 16:19:20 UTC