W3C home > Mailing lists > Public > public-qt-comments@w3.org > December 2015

[Bug 29346] [XP31] XPath-style currying, or the arrow operator, may require a bit more specification

From: <bugzilla@jessica.w3.org>
Date: Fri, 18 Dec 2015 10:24:51 +0000
To: public-qt-comments@w3.org
Message-ID: <bug-29346-523-k6AUh9xog6@http.www.w3.org/Bugs/Public/>
https://www.w3.org/Bugs/Public/show_bug.cgi?id=29346

Michael Kay <mike@saxonica.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |mike@saxonica.com

--- Comment #3 from Michael Kay <mike@saxonica.com> ---
I agree that the ArrowOperator is very poorly specified and in particular that
it is entirely unclear what happens if the ArgumentList contains a PlaceHolder.

I'm inclined to interpret the spec as saying that it CAN contain a PlaceHolder,
because (a) the grammar allows it, and (b) it makes sense semantically. But I
don't think we have any tests that demonstrate this. With this interpretation,
I would be inclined to rewrite the spec as follows:

An ArrowExpr is alternative syntax for a *static function call* or *dynamic
function call*. 

* If the ArrowFunctionSpecifier is an EQName, then the expression A => f()
(where A is any UnaryExpr and f is the EQName) is equivalent to the static
function call f(A), and the expression A => f(ARGS) (where ARGS is a
comma-separated sequence of *Argument*s) is equivalent to the static function
call f(A, ARGS).

* If the ArrowFunctionSpecifier is a VarRef or ParenthesizedExpr, then the
expression A => E() (where A is any UnaryExpr, and E is the VarRef or
ParenthesizedExpr) is equivalent to the dynamic function call E(A), and the
expression A => E(ARGS) (where ARGS is a comma-separated sequence of
*Argument*s) is equivalent to the dynamic function call E(A, ARGS).

In both cases the ArgumentList may contain a PlaceHolder, in which case the
ArrowExpr is a *partial function application*.

The equivalence of an ArrowExpr to a static or dynamic function call applies
also to error conditions. For example, a type error occurs if the result of
evaluating the VarRef or ParenthesizedExpr is not a function, or if it is a
function with incorrect arity. 

This syntax is particularly useful when conventional function call syntax leads
to an expression with deeply nested parentheses. For instance, the following
expression:

tokenize((normalize-unicode(upper-case($string), 'NFC')), ",\s*")

can be replaced by the more easily readable:

$string => upper-case() => normalize-unicode('NFC') => tokenize(",\s*")

-- 
You are receiving this mail because:
You are the QA Contact for the bug.
Received on Friday, 18 December 2015 10:24:53 UTC

This archive was generated by hypermail 2.3.1 : Friday, 18 December 2015 10:24:54 UTC