[Bug 25444] New: [XP3.1] Replace pseudo-type "numeric" with a union type

https://www.w3.org/Bugs/Public/show_bug.cgi?id=25444

            Bug ID: 25444
           Summary: [XP3.1] Replace pseudo-type "numeric" with a union
                    type
           Product: XPath / XQuery / XSLT
           Version: Last Call drafts
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: XPath 3.1
          Assignee: jonathan.robie@gmail.com
          Reporter: mike@saxonica.com
        QA Contact: public-qt-comments@w3.org

We have a number of functions whose signature includes the pseudo-type
"numeric", and explain this by saying that there are actually multiple function
signatures with different types (decimal, double, float, numeric). We say in
section 1.4 that fn:abs(numeric) is actually four different functions with
different signatures, but in XQuery ยง3.1.6 we say "fn:abs#1 references the
fn:abs function" as if there were only one.

This is a fudge and a mess, and it is quite unnecessary now that we support
union types. We should define these functions with a signature that expects a
supplied type of union(decimal, float, double), and returns the same as its
result type, and all the problems go away. In addition, if we do it using a
union type, then user-defined functions on numeric values can adopt the same
approach (well, actually, they already can).

The only complications are how to introduce a new built-in union type.

Rather than make all the effort to decide what name and namespace such a type
should have, I propose that we make it anonymous, and allow anonymous plain
union types to be declared using ItemType syntax at the point of use:

"union" "(" QName ("," QName)* ")"

We then not only solve the "numeric" problem, but also provide a powerful
capability for users at the same time, being able to declare union types and
use them freely without pre-declaration in a schema, e.g.

<xsl:variable name="d" 
    select="@timestamp cast as union(xs:gYearMonth, xs:date)"/>

-- 
You are receiving this mail because:
You are the QA Contact for the bug.

Received on Thursday, 24 April 2014 17:24:30 UTC