=和!=的语义 [英] Semantics of = and !=
问题描述
在XQuery中,
("foo", "bar") = ("foo", "bar")
产生值true
.这似乎很明显.但我注意到了
yields the value true
. That seems obvious. But I noticed that
("foo", "bar") != ("foo", "bar")
也也产生true
,我发现这很令人惊讶.我知道我可以将=
与not($x = $y)
取反,并且我已经注意到=
具有某种集合交集语义,但是任何人都可以解释!=
的语义,和/或为其提供参考吗?
also yields true
, which I found rather surprising. I know that I can negate =
with not($x = $y)
and I've noticed that =
has some kind of set intersection semantics, but can anyone explains the semantics of !=
, and/or provide a reference for it?
推荐答案
可在 XQuery的文档在"3.5.2常规比较"部分中.
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)
读到推理,它读起来就像是雾化规则一个要怪这里.如果元素是untypedAtomic,则解析器可以自由地猜测"应该如何进行比较,从而允许基于元素本身而不是任何操作员行为的操作差异.
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.
这篇关于=和!=的语义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!