Re: [xsl] () eq () vs () = ()

Subject: Re: [xsl] () eq () vs () = ()
From: Andrew Welch <andrew.j.welch@xxxxxxxxx>
Date: Mon, 3 Oct 2011 11:27:11 +0100
On 3 October 2011 11:11, Brandon Ibach
<brandon.ibach@xxxxxxxxxxxxxxxxxxx> wrote:
> On Sat, Oct 1, 2011 at 12:01 PM, Andrew Welch <andrew.j.welch@xxxxxxxxx> wrote:
>>> deep-equal(A, B) means (count(A) eq count(B) and every $i in 1 to count(A)
>>> satisfies A[$i] eq B[$i]). Therefore deep-equal((), ()) is true.
>>
>> Is it fair to say deep-equal could mean:
>>
>> every $i in 1 to max((count(A), count(B))) satisfies A[$i] eq B[$i]
>>
>> which would then return false, as its only the length check that is
>> causing it to return true (and thats only there to avoid also checking
>> every item in B is equal to A)
>
> Even if this is a reasonable definition for deep-equal (disregarding
> the fact that, as Michael pointed out, it doesn't properly handle
> values such as NaN or nodes), your assertion that it would return
> false for deep-equal((), ()) does not hold

The point I was trying to make was if you don't compare the lengths,
it won't return true because there is nothing to compare, just like =.

You could of course flip that around and say if you start from a
position of true, there's nothing to make that false, but as = returns
false, it would make sense to me to start from a position of false.


> I'd echo the comments of others regarding the purpose of deep-equal
> (identifying an equivalent structure with equivalent values, node
> names and/or node kinds), the structural equivalence of two empty
> sequences, and the very much non-intuitive results that would occur if
> it didn't work the way it did in this case.

...but there are no equivalent structures or values?


> That said, I agree that () eq () not returning false() is not
> necessarily intuitive or always convenient for the XSLT crowd, but as
> a nod of compatibility for the database/SQL community, which drives
> much of XQuery, it seems a reasonable thorn to bear, given the
> seemingly rare situations in which it might cause issues.

Yeah I'm happy with a 'just because' reason, but I don't yet know the
benefit of returning () over false, and in what situation you would
use that.



-- 
Andrew Welch
http://andrewjwelch.com

Current Thread