- From: <bugzilla@jessica.w3.org>
- Date: Tue, 06 Oct 2015 15:30:16 +0000
- To: public-qt-comments@w3.org
https://www.w3.org/Bugs/Public/show_bug.cgi?id=27059
--- Comment #6 from Jonathan Robie <jonathan.robie@gmail.com> ---
I started adding this to the spec, but had some concerns with parts of this as
I went.
(In reply to Michael Kay from comment #0)
> Although the spec is probably technically correct, it would be worth some
> explanation of how function coercion interacts with maps and arrays.
>
> Firstly, if the expected type is a map or array type, then function coercion
> does not apply. That's because the expected type is not [written as a]
> TypedFunctionTest (bullet 3 of 3.1.5.2).
I assume that does not need to be stated explicitly, since lots of other things
aren't TypedFunctionTest.
> Note that the bullets here are
> rather varied in style, for example:
>
> "If the expected type calls for a single item or optional single item"
> "If the expected type is xs:string or xs:string?"
> "If the expected type is a sequence of a generalized atomic type"
>
> It would be better if they were all phrased in terms of how the type is
> expressed syntactically.
Do you mean by adding a phrase like "written as a"? Or were you asking for
something else?
> Secondly, if the expected type is (expressed as) a TypedFunctionTest, and
> the actual supplied value is a map or array, then function coercion does
> apply. For example, fn:sort expects a function item of type function(item())
> as xs:anyAtomicType*, and it is acceptable to supply a map as the value of
> this argument.
I think you're simply pointing out that arrays and maps are functions? If so,
it may be worth mentioning in a NOTE, e.g.
* If the expected type is a TypedFunctionTest (possibly with an occurrence
indicator *, +, or ?), function coercion is applied to each function in the
given value.
NOTE: Maps and arrays are functions, so function coercion applies to them as
well.
> If a map $M is passed, the rules of function coercion say
> that this is equivalent to passing the function
>
> function($key as item()) as xs:anyAtomicType* {
> $M($key)
> }
>
> which in general (unless there is an atomization failure) will work; the
> sort key for any value not present in the map is an empty sequence.
>
> It's certainly worth a note or an example to explain this.
I would probably use the NOTE I suggested above, and add an example in the
section on function coercion.
> Thirdly, if the expected type is written as function(*), then it is legal to
> supply a map or array as the value of the argument, but no coercion takes
> place.
I think this is covered by the above NOTE, and should also be covered in the
example.
--
You are receiving this mail because:
You are the QA Contact for the bug.
Received on Tuesday, 6 October 2015 15:30:18 UTC