W3C home > Mailing lists > Public > public-qt-comments@w3.org > September 2016

[Bug 29870] New: Tuple types

From: <bugzilla@jessica.w3.org>
Date: Mon, 26 Sep 2016 06:42:55 +0000
To: public-qt-comments@w3.org
Message-ID: <bug-29870-523@http.www.w3.org/Bugs/Public/>
https://www.w3.org/Bugs/Public/show_bug.cgi?id=29870

            Bug ID: 29870
           Summary: Tuple types
           Product: XPath / XQuery / XSLT
           Version: Candidate Recommendation
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Requirements for Future Versions
          Assignee: jim.melton@acm.org
          Reporter: mike@saxonica.com
        QA Contact: public-qt-comments@w3.org
  Target Milestone: ---

A common use case for maps is to represent composite structures such as the
result of fn:random-number-generator, which is a map containing 

number: an xs:double
next: a function
permute: a function

The problem about using maps for such structures is that we can't describe or
constrain their type very accurately: this example simply becomes
map(xs:string, item()).

We could introduce tuple types simply as new syntax for constraining the type
of a map.

declare function fn:random(...) as 
   tuple{number : xs:double, 
         next : function(*),
         permute : function(item()*) as item()*}

The instances of this type would still be maps, and they would still be
instances of map(xs:string, item()), and one could use all the same operations
(e.g. random($seed)?permute($x)), but the new item type syntax would allow the
required type to be specified more descriptively and precisely, and would allow
better static type checking.

The feature has been prototyped in Saxon: see
http://dev.saxonica.com/blog/mike/2016/09/tuple-types-and-type-aliases.html

(In this particular example it would be nice to be able to make the type
recursive, since the "next" function also returns tuples of this type; but
that's a separate requirement).

-- 
You are receiving this mail because:
You are the QA Contact for the bug.
Received on Monday, 26 September 2016 06:43:09 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 16:58:02 UTC