=和!=的语义 [英] Semantics of = and !=

查看:89
本文介绍了=和!=的语义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在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)

读到推理,它读起来就像是雾化规则

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆