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 12:07:06 +0000
To: public-qt-comments@w3.org
Message-ID: <bug-29346-523-Eip6P27KzI@http.www.w3.org/Bugs/Public/>

--- Comment #5 from Abel Braaksma <abel.braaksma@xs4all.nl> ---
Hmm, I just realize something. I don't think we can so easily allow the
placeholder syntax. Your current proposal makes:

a => concat('b', ?, 'd')

resolve to:

concat(a, 'b', ?, 'd')

while it will make:

a => (concat('b', ?, 'd'))()

resolve to:

concat('b', a, 'd')

and it will make the following illegal:

a => concat('b', ?, 'd')()

I am inclined to suggest that we unify these calls to mean the same. I can't
think of a use-case why it is handy to treat an arrow expr with an argument
list with a placeholder as returning a function that takes one or more
arguments. Besides, it simply "reads" exactly the other way: the arrow operator
(to me at least) suggests replacing the question mark on the RHS if there is

To that affect, I suggest to change your proposal slightly, by
adding/augmenting as follows:

In the expression A => F(ARGS?), where A is UnaryExpr and F is
ArrowFunctionSpecifier ArgumentList, rewrite as follows:
* If F(ARGS?) is a *function call* but not a *partial function application*, it
is rewritten as the partial function application:
   a) if ARGS is empty, let FA be F(?)
   b) if ARGS is not empty, let FA be F(?, ARGS)
* If F(ARGS?) is a *partial function application*, FA is F(ARGS)
* The first ArgumentPlaceHolder in FA is now replaced by A and evaluated as
described in

I think this works with the following expressions:

a => concat('b', ?)
becomes step 1: concat('b', ?)
becomes step 2: concat('b', a)

a => concat('b', 'c')
becomes step 1: concat(?, 'b', 'c')
becomes step 2: concat(a, 'b', 'c')

a => concat(?, ?, 'd')
becomes step 1: concat(?, ?, 'd')
becomes step 2: concat(a, ?, 'd')

a => (let $c := concat#2 return $c)('b', ?)
becomes step 1: (let $c := concat#2 return $c)('b', ?)
becomes step 2: (let $c := concat#2 return $c)('b', a)

a => (let $c := concat#2 return $c)('b')
becomes step 1: (let $c := concat#2 return $c)(?, 'b')
becomes step 2: (let $c := concat#2 return $c)(a, 'b')

let $c := concat#3 return a => $c('b', 'c')
becomes step 1: ... return $c(?, 'b', 'c')
becomes step 2: ... return $c(a, 'b', 'c')

a => (function($b) { $b + 1 })()
becomes step 1: (function($b) { $b + 1 })(?)
becomes step 2: (function($b) { $b + 1 })(a)

I think that this way it is more "natural" and it is also (still) a valid
interpretation of the way the current text is written. It emphasizes the fact
that ArrowExpr is a shorthand, or a macro if you wish.

However, I realize that it deviates in details from your proposal.

PS: (though probably too late in CR), I think we can do without the
superfluous, but required parentheses at the end for everything except the
EQName variant, allowing the RHS to become an expression that returns just a
function item with arity 1.

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

This archive was generated by hypermail 2.3.1 : Friday, 18 December 2015 12:07:10 UTC