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 29509 - Functions: External, Implementation-Defined, Host Language
Summary: Functions: External, Implementation-Defined, Host Language
Status: RESOLVED FIXED
Alias: None
Product: XPath / XQuery / XSLT
Classification: Unclassified
Component: XPath 3.1 (show other bugs)
Version: Candidate Recommendation
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: 2016-03-01 14:48 UTC by Jonathan Robie
Modified: 2016-06-07 19:37 UTC (History)
3 users (show)

See Also:


Attachments

Description Jonathan Robie 2016-03-01 14:48:38 UTC
The current internal draft has formal definitions for various kinds of functions.  The relationship between host language functions, external functions, and implementation-defined functions is confusing and not terribly helpful.  

The definition of external function has been in drafts since February 2014, but it defines external in terms of "the query environment".

<quote src="XQuery31" status="current internal">
external function

External functions are functions that are implemented outside the query environment.
</quote>

It's probably better to define it syntactically:

<quote src="XQuery31" status="proposed">
external function

External functions are functions identified with the 'external' keyword in the query prolog.
</quote>

In XQuery, Appendix C tells us that implementations can augment the built-in functions with additional functions, but there is currently no term that refers to these functions.  The term implementation-defined function is a natural for this, but it is not yet up to the task:

<quote src="XQuery31" status="current internal">
[Definition: An implementation-defined function is a function that is implementation-defined.].
</quote>

It's probably better to define this in terms of augmenting the static and dynamic contexts:

<quote src="XQuery31" status="current internal">
[Definition: An implementation-defined function is a function that is provided by an implementation that augments the *statically known function signatures* and/or *named functions*.]  Functions imported from standard libraries are also considered implementation-defined functions, and the implementation must document which libraries it imports.
</quote>

The current definition of host language function is:

[Definition: A host language function is a function defined by the host language.]

This definition may not be needed, and did not exist until recently. Can we just get rid of it?
Comment 2 Michael Dyck 2016-03-01 15:23:48 UTC
I think Michael Kay's post to public-xsl-query is pertinent here:
https://lists.w3.org/Archives/Public/public-xsl-query/2016Feb/0019.html
Comment 3 Michael Kay 2016-03-01 16:00:09 UTC
We've recently changed the definition of "extension function" in XSLT to "a named function added to the static or dynamic context using mechanisms outside the scope of this specification", with non-normative notes to explain what this means in practice.

In XQuery there's the complication that external function may be declared in the prolog, but there can also be functions that aren't declared. If the term "external function" is restricted to those that are declared in this way, then what are the undeclared ones called? How about some alignment - call them "extension functions".
Comment 4 Jonathan Robie 2016-06-07 13:39:20 UTC
I propose to close this bug as follows:

1. Keep the following definition for external function, which has been used since XQuery 1.0 (https://www.w3.org/TR/xquery/#dt-external-function)

[Definition: External functions are functions that are implemented outside the query environment.]

Note that this section implies that these two kinds of functions are external functions:

* an XQuery implementation might provide a set of external functions in addition to the core function library
* an XQuery implementation may provide a facility whereby external functions can be implemented 

2. Define implementation-defined functions as follows:

... an XQuery implementation might provide a set of external functions in addition to the core function library. [Definition: an *implementation-defined function* is an external function provided by the implementation.]

3. (Possibly) Define host language function as follows:

[Definition: A host language function is a function defined by the host language.]

XQuery does not have host language functions, but XSLT does. XSLT is not an "implementation of" XPath, it is a host language.
Comment 5 Jonathan Robie 2016-06-07 13:42:48 UTC
Incidentally, I also think the following text should be changed:

An XQuery implementation may provide a facility whereby external functions can be implemented using a host programming language, but it is not required to do so. 

The term host language is well defined for XPath, but not for XQuery. It's probably best to simply delete the term:


An XQuery implementation may provide a facility whereby external functions can be implemented, but it is not required to do so.
Comment 6 Jonathan Robie 2016-06-07 16:54:42 UTC
Another clarification: change "External functions are identified by the keyword external" to "In function declarations, external functions are identified by the keyword external".
Comment 7 Jonathan Robie 2016-06-07 19:32:33 UTC
In today's telcon, we voted to resolve this by accepting comment #4, comment #5, and comment #6.
Comment 8 Michael Kay 2016-06-07 19:37:44 UTC
Under the definition of "External functions" in 2.18, I would be inclined to add the Note:

Note: Section 2.1.1 makes clear that the set of function signatures available in the static context may include signatures of functions provided by an implementation or via an implementation-defined API. Calls to such functions may appear in a query whether or not the query prolog includes a relevant function declaration with the keyword "external"; and such functions fall within the definition of the term "external function" whether or not they are declared in the query prolog. Declaring an external function in the query prolog is useful because it makes it clear both to the query processor and to human readers that the query is dependent on a particular external function. Declaring the signature of the external function may also enable better type checking and better diagnostics.