任何语言都使用“=/=”吗?用于表示不等于运算符
- 是否有任何编程语言使用
=/=
来表示不等于? - 扫描仪识别这样的操作员是否存在词汇上的困难?还是历史上确实如此?
[注意:这不是家庭作业问题。我只是好奇。]
- Does any programming language use
=/=
for not-equal? - Are there any lexical difficulties for scanners to recognize such an operator? Or was it the case historically?
[Note: this is NOT a homework question. I'm just curious.]
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
Erlang 用它来表示完全不等于。
一般来说,扫描仪识别这样的令牌应该不会有任何困难(通过示例证明:Erlang;-)
Erlang uses it to denote exactly not equal to.
Also generally there shouldn't be any difficulties for scanners to recognize such a token (proof by example: Erlang ;-)
在 Erlang
=/=
中,正如 Bytecode Ninja 所说 的意思是“完全不等于”。 Erlang 的表示法深受 Prolog 的影响,因此 Prolog 也使用该运算符也就不足为奇了。有几种语言使得定义运算符变得微不足道。哈斯克尔就是这样的一个。=/=
没有在 Haskell 标准中定义,但是定义它是微不足道的:这可以在类似函数调用的语法中使用:
或者作为内联运算符:
语义将取决于当然是实施。
我认为 Common Lisp
weenies用户也可以编写某种使用该序列的阅读器宏,但我并不肯定。In Erlang
=/=
, as noted by Bytecode Ninja means "exactly not equal to". The notation of Erlang is strongly influenced by Prolog so it should come as no surprise that Prolog uses that operator too. There are several languages which make defining operators trivial. Haskell would be one such.=/=
isn't defined in the Haskell standard, but defining it would be trivial:This could then be used in function call-like syntax:
Or as an inline operator:
The semantics would depend on the implementation, of course.
I think that Common Lisp
weeniesusers could write some kind of reader macro that used that sequence too, but I'm not positive.顺便说一下,Java 有:
>
(大于)>>
(有符号右移)>>=
(有符号右移复合赋值)>>>
(无符号右移)>>>=
(无符号右移复合赋值)>< /code> (关闭泛型类型参数,可嵌套)
>>
、>>
、>>>>
、...以及他们都工作得很好。
相关问题
By the way, Java has:
>
(greater than)>>
(signed right shift)>>=
(signed right shift compound assignment)>>>
(unsigned right shift)>>>=
(unsigned right shift compound assignment)>
(closing generic type parameter, nestable)>>
,>>>
,>>>>
, ...and they all work just fine.
Related question
是的,Erlang 使用此符号作为一个符号其表示形式为“不等于”。
Erlang 是一种对并发有强大支持的语言,最初在爱立信内部设计并使用为电话交换机编写软件,但现在在国外广受欢迎。
Yes, Erlang uses this symbol as one of its representations for "not equal".
Erlang is a language with strong support for concurrency, originally designed within Ericsson and used for writing software for telephone exchanges, but now gaining significant popularity outside.
您可能需要查看Fortress 介绍性幻灯片。 Fortess 使用 =/= 来检查不等式。我想你会寻找语言的可读性。如果是这样的话,我可以说 Fortess 代码可以被渲染成看起来非常整洁的 TeX。
Project Fortress Old Site(已移至 java.net)
You may want to check out Fortress Introductory Slides. Fortess uses =/= for checking inequality. I suppose you look for readability in languages. If that's the case then I can tell that Fortess code can be rendered into very neat looking TeX.
Project Fortress Old Site (moved to java.net)
+=
、??
等任何其他运算符难多少。但是,键入这样的运算符非常麻烦。甚至
!=
也会更简单。+=
,??
, etc.However, it's very cumbersome to type such an operator. Even
!=
will be simpler.Google 代码搜索 for
=/=
没有出现任何明显的结果,所以我不会说什么主流。您想要的任何运算符都不会有任何问题,计算机只会查找
=/=
而不是!=
或<> 或您的语言使用的任何内容。
有一些非常奇怪的语言,例如 BrainFuck 语言 (link)
这是“Hello World”的代码。
A google code search for
=/=
doesn't turn up anything obvious, so I would say nothing mainstream.There wouldn't be any issues with any operator you want, the computer would simply look for
=/=
instead of!=
or<>
or whatever your language uses.There are some really weird languages out there like BrainFuck language (link)
That is code for "Hello World".