RE: Discussion of op:same-key

Not entirely sure this is relevant for the discussion, but we hit a similar problem when implementing fn:round for floating point values. Already in FO30 the spec said (under 4.4.4 fn:round, FO30):

" the argument is cast to xs:decimal using an implementation of xs:decimal that imposes no limits on the number of digits that can be represented"

Since in edge cases there is a difference in outcome *unless* you do as written here, we needed to bite the bullet and implement an arbitrary precision decimal representation. We currently do not use it for all operations (and the J# suggestion in the bug report is extremely slow and unmaintained, but other libraries are available online), but if you support it for fn:round correctly, you could also support it for map keys, right?

While I have sympathy for the arguments presented in this thread, I think that it has been impossible for a while to implement FO30/31 without having an arbitrary precision decimal library (though many parts of the spec suggests this should be possible, clearly it is not). From that perspective, the implementation burden was already high (for fn:round and the like).

I am surprised about example below, surely because "xs:float(33554433) eq 33554433 = true()", one would expect "no surprise" to be returned?

Cheers,
Abel

> -----Original Message-----
> From: Tim Mills [mailto:tim@cbcl.co.uk]
> Sent: Thursday, June 02, 2016 2:00 PM
> To: public-xsl-query@w3.org
> Subject: Re: Discussion of op:same-key
> 
> On 02/06/2016 11:31, Michael Kay wrote:
> >
> > Given
> >
> > let $a := <a size="3"/>
> >
> > let $m := map{ $a/@size+1, $a }
> >
> > people expect $m(4) to return the <a> element. We don't want them to
> have to start thinking about the fact that @size+1 is actually an xs:double
> rather than an integer.
> >
> On that basis, a user might also expect
> 
> let $result := map {
>                xs:float(33554433): "no surprise"
>              }
> return $result?33554433
> 
> to return "no surprise", but instead the user will end up surprised,
> having been led astray by having seen this work for smaller integers.
> The rule "use a key of matching type" is one the user would learn early
> on.  Learning "beware the precision of floating point numbers" might
> take a little longer.
> 
> Cheers,
>      Tim
> 

Received on Thursday, 2 June 2016 12:36:11 UTC