Re: New Functions

In response to feedback, I'm changing the proposed terminology so "tuple" becomes "record". Although usage varies, there seems to be a bit of a consensus that in a tuple, components are identified by position, whereas in a record or struct, they are identified by name.  (SQL of course muddles this, as it does many things.) The 4.0 proposal is for a structure with named and unordered components, so "record" seems a more appropriate name.

There might also be scope for extending sequence type and/or array type syntax for describe heterogeneous sequences/arrays, but I don't particularly want to encourage that usage, and I think maps described using record types generally serve the use cases better.  For a simple case like representing complex numbers my preference is to use a map with keys "r" and "i" (for example) rather than a fixed-length sequence or array with length 2.

Michael Kay
Saxonica



> On 30 Nov 2020, at 15:20, Dimitre Novatchev <dnovatchev@gmail.com> wrote:
> 
> > I am having a hard time following the different suggestions and merging
> > them mentally, aren't tuples supposed to have a field name in any case
> > as they are just specialized maps?
> >  https://www.saxonica.com/qt4specs/XP/xpath-40-diff.html#id-tuple-test <https://www.saxonica.com/qt4specs/XP/xpath-40-diff.html#id-tuple-test>
> >   
> > That tuple of N things looks just like an array of (N) things to me.  
> 
> Good question, @Martin Honnen <mailto:Martin.Honnen@gmx.de> !
> 
> As tuples are something new, I also can't go into details. Seems I misread the syntax of TupleTest in https://www.saxonica.com/qt4specs/XP/xpath-40-diff.html#id-grammar <https://www.saxonica.com/qt4specs/XP/xpath-40-diff.html#id-grammar>
> 
> Let me re-write:
> 
>  fn:partition-at($seq as item()*,
>                       $n as xs:integer)
>          as tuple(first ? item()*, second ? item()*)
> 
> @Michael Kay <mailto:mike@saxonica.com> Could you confirm that this is now correct?
> 
> Thanks,
> Dimitre
> 
> On Mon, Nov 30, 2020 at 1:36 AM Martin Honnen <martin.honnen@gmx.de <mailto:martin.honnen@gmx.de>> wrote:
> Am 29.11.2020 um 23:53 schrieb Dimitre Novatchev:
> > Now that we have thetuple/ record type, we can have some very useful
> > functions on collections (both sequences and arrays) that return more
> > than one result,
> > or to say it in other words, return a tuple of Nthings, whereN > 1.
> >
> > fn:partition-at($seq as item()*,
> >
> >                  $n as xs:integer)
> >
> >         as tuple(item()*, item()*)
> 
> I am having a hard time following the different suggestions and merging
> them mentally, aren't tuples supposed to have a field name in any case
> as they are just specialized maps?
> https://www.saxonica.com/qt4specs/XP/xpath-40-diff.html#id-tuple-test <https://www.saxonica.com/qt4specs/XP/xpath-40-diff.html#id-tuple-test>
> 
> That tuple of N things looks just like an array of (N) things to me.
> 
> >
> > , returns a tuple of two sequences, the first of which is
> >
> > subsequence($seq, 1, $n), and the second is:
> >
> > subsequence($seq, $n +1)
> >
> 
> Or how would one access a the first and second field in the result of
> fn:partition-at($seq, $n)?
> 
> 
> 
> 
> 
> 

Received on Monday, 30 November 2020 15:32:34 UTC