[Bug 6133] New: Definition of user-defined function, function-body could be improved

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

           Summary: Definition of user-defined function, function-body could
                    be improved
           Product: XPath / XQuery / XSLT
           Version: Working drafts
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: XQuery 1.1
        AssignedTo: jonathan.robie@redhat.com
        ReportedBy: jonathan.robie@redhat.com
         QAContact: public-qt-comments@w3.org


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.]


-- 
Configure bugmail: http://www.w3.org/Bugs/Public/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.

Received on Wednesday, 1 October 2008 15:29:39 UTC