[Bug 12951] Simple mapping operator

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

Michael Kay <mike@saxonica.com> changed:

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

--- Comment #2 from Michael Kay <mike@saxonica.com> 2011-06-14 07:42:06 UTC ---
Thanks for bringing this back to the WGs attention.

There's been a lot of work in the last few months trying to add a new data
structure - maps - to the language, with associated functions, operators, and
types. The current status is that this is accepted by the XSL WG (where it is
needed for some streaming use cases, as well as being generally useful for
other things), but there is some resistance to adding it to XQuery, either on
principle or on timing grounds. Associated with this we found that many of the
examples using maps would also benefit from the simple mapping operator, and
this too is present in the current XSLT draft, though it has not yet been
proposed to the joint WGs.

Historically, I think the simple mapping operator would have made it into XPath
2.0 if we had been able to agree on a suitable operator symbol. There seems to
be some resistance to "!" perhaps because the languages that have used this
symbol in a similar role are unfamiliar to most WG members (and probably to
most of our users as well, in fairness). But no-one seems to have any better
suggestions ("->" occasionally surfaces, but has the drawback that a space is
needed before the hyphen). At a late stage before XPath 2.0 was released the
requirement for a simple mapping operator was partly satisfied by overloading
the semantics of "/" to allow atomic values on the RHS: an unfortunate
compromise in my view, though it's better than nothing.

You mention jQuery's chaining mechanism. We've also looked at this in the XSL
WG, for example allowing 

$uri -> substring-before('#') -> substring-after('http://')

Here, rather than the LHS setting the dynamic context for evaluation of the
RHS, there's simply an alternative function call notation where a->f(x)
replaces f(a,x). It's a different solution than the simple mapping operator but
has some of the same benefits, in particular, avoiding the deeply-nested
function calls and the right-to-left order of evaluation.

-- 
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 Tuesday, 14 June 2011 07:42:08 UTC