简体   繁体   English

总是有三等于的语言

[英]languages that always had triple equals

What popular programming languages were intentionally designed from the beginning to have both === and == (and require the programmer to figure out which one to use). 从一开始就有意设计了哪些流行的编程语言同时具有===和==(并且要求程序员找出使用哪一种)。
Javascript, PHP, ruby (and probably others) have a triple equals operator today. Javascript,PHP,ruby(可能还有其他人)今天有一个三等号运算符。 But, it is not clear if this was a deliberate design decision, or happened only by accident (perhaps because the language started with double equals, but at some point it was discovered that double equals wasn't quite doing what people wanted it to do). 但是,目前尚不清楚这是一个刻意的设计决定,还是只是偶然发生(也许是因为语言以双等号开头,但在某些时候发现双等于并不是人们想要它做的事情)。
Specifically in javascript, does anyone remember if it had the triple equals when it first came out? 特别是在javascript中,有没有人记得它第一次出现时是否有三等号?

Since my memory isn't very reliable, I can't say that I remember either or, but since ECMA has kindly kept all revisions of the ECMA-262 specification, it's possible to defer from reading them when the "The Strict Equals Operator" was introduced into the language. 由于我的记忆不是很可靠,我不能说我记得或者,但是因为ECMA已经保留了ECMA-262规范的所有修订版,所以当“严格等于运算符”时,可以推迟阅读它们。被引入语言。

I can't find any mention of it in neither ECMA-262 1st Edition , nor ECMA-262 2nd Edition , but in ECMA-262 3rd Edition we find mention of it in chapter 11.9.4 (page 56). 我无法在ECMA-262第1版ECMA-262第2版中找到任何提及,但在ECMA-262第3版中,我们在第11.9.4章(第56页)中找到了它。 The natural conclusion to draw from this is thus: No, JavaScript did not have === when it first came out. 因此得出的自然结论是:不,当它第一次出现时,JavaScript没有===

Since the other languages you mention aren't (as far as I know) ratified in any standardisation body, I guess it's harder to find old revisions of the language's specification, if there is any such thing as a specification for the language at all. 由于你提到的其他语言(据我所知)在任何标准化机构中都没有批准,我想如果有任何语言规范,那么就很难找到语言规范的旧版本。

It's important to note, however, that the meaning of === in Ruby can be widely different than in JavaScript or PHP (where it is fairly similar). 然而,值得注意的是,Ruby中===的含义可能与JavaScript或PHP(它非常相似)中的含义大不相同。 In Ruby, it's usually used for "subsumption", ie to check whether something exists within something else (a set, for instance), while in the two other langauges, it's used for strict equality checking, which means no type conversion is performed on either side of the operator before applying it. 在Ruby中,它通常用于“包含”,即检查某些内容是否存在于其他内容中(例如,一个集合),而在另外两个语言中,它用于严格的相等性检查,这意味着不执行类型转换。在应用之前,操作员的任何一方。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM