- 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.]
=/=
for not-equal?[Note: this is NOT a homework question. I'm just curious.]
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".
+=
, ??
, etc.However, it's very cumbersome to type such an operator. Even !=
will be simpler.
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.
Erlang uses it to denote exactly not equal.
Also generally there shouldn't be any difficulties for scanners to recognize such a token (proof by example: 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.
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:
(=/=) x y = ....
This could then be used in function call-like syntax:
(=/=) 5 6
Or as an inline operator:
5 =/= 6
The semantics would depend on the implementation, of course.
I think that Common Lisp weenies users could write some kind of reader macro that used that sequence too, but I'm not positive.