This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 6133 - [XQuery 1.1] Definition of user-defined function, function-body could be improved
Summary: [XQuery 1.1] Definition of user-defined function, function-body could be impr...
Status: RESOLVED FIXED
Alias: None
Product: XPath / XQuery / XSLT
Classification: Unclassified
Component: XQuery 3.0 (show other bugs)
Version: Working drafts
Hardware: PC Linux
: P2 normal
Target Milestone: ---
Assignee: Jonathan Robie
QA Contact: Mailing list for public feedback on specs from XSL and XML Query WGs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-10-01 15:29 UTC by Jonathan Robie
Modified: 2008-11-03 18:27 UTC (History)
2 users (show)

See Also:


Attachments

Description Jonathan Robie 2008-10-01 15:29:06 UTC
The definition of a user-defined function in 4.5 Function Declarations has two flaws:

1. It's not clear whether the function body is the enclosed expression or the expression it contains.
2. It is not similar to the definition of external functions.

Here are the current definitions:

[Definition: For a user-defined function, the function declaration includes an expression called the function body that defines how the result of the function is computed from its parameters.]. 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.

[Definition: External functions are functions that are implemented outside the query environment.] For example, an XQuery implementation might provide a set of external functions in addition to the core function library described in [XQuery 1.0 and XPath 2.0 Functions and Operators]. External functions are identified by the keyword external. The purpose of a function declaration for an external function is to declare the datatypes of the function parameters and result, for use in type checking of the query that contains or imports the function declaration.

I think this could be improved by adding a production for FunctionBody and rephrasing the definition:
 	
<proposed>
FunctionDecl 	   ::=    	"declare" ("deterministic" | "nondeterministic")? "function" QName "(" ParamList? ")" ("as" SequenceType)? (FunctionBody | "external")

ParamList 	   ::=    	Param ("," Param)*

Param 	   ::=    	"$" QName TypeDeclaration?

TypeDeclaration 	   ::=    	"as" SequenceType

FunctionBody ::= EnclosedExpr


[Definition: User defined functions are functions that contain a function body, which provides the implementation of the function using an XQuery expression.]
Comment 1 Michael Kay 2008-10-01 17:41:52 UTC
>the enclosed expression or the expression it contains

I don't know if this helps, but I got into a brief muddle understanding this comment because it seems "enclosed expression" is one of those phrases that looks adjectival but isn't - an "enclosed expression" is not an expression. Perhaps it would help to call it a "block".
Comment 2 Jonathan Robie 2008-11-03 18:27:42 UTC
At last week's F2F, we decided this is up to the discretion of the editor.