Re: Discussion of op:same-key

I think the point is that the double is implicit, unlike the explicitly created float in your example.  And, with the double there will be no surprises until 2^53.  JavaScript has a similar surprise boundary:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_SAFE_INTEGER

Thanks,
Josh

> On Jun 2, 2016, at 4:59 AM, Tim Mills <tim@cbcl.co.uk> wrote:
> 
> 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 Monday, 6 June 2016 15:28:47 UTC