Semantics of = and !=

后端 未结 2 1631
慢半拍i
慢半拍i 2021-01-21 01:43

In XQuery,

(\"foo\", \"bar\") = (\"foo\", \"bar\")

yields the value true. That seems obvious. But I noticed that

(         


        
2条回答
  •  面向向阳花
    2021-01-21 02:14

    This can be found in the documentation for XQuery under section "3.5.2 General Comparisons".

    The following example contains two general comparisons, both of which are true. This example illustrates the fact that the = and != operators are not inverses of each other.

    (1, 2) = (2, 3)
    (1, 2) != (2, 3)
    

    Reading into the reasoning, it reads to me as if the rules of Atomization are to blame here. If the elements are untypedAtomic, then the parser is free to "guess" at how the comparison should be made which allows for the difference in operations based on the elements themselves rather than on any operator behavior.

提交回复
热议问题