lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Roberto Ierusalimschy wrote:

Why is the ~= operator the != operator in Lua in the first place? Perhaps someone could share this bit of information?

First, `~=' is not the `!=' operator in Lua. `~=' is the "not equal"
operator ;)

Back in 1993 (when we started Lua) there was no Java, no Python (at
least to a general audience), no Php, Perl was known only to the
initiated. At that time, C-like syntax was not dominant as it is now.

Even today a lot of languages do not use `!=': Ada, Haskell, Eiffel, and
Fortran90 use `/='; Icon, Dylan, Smalltalk (and Lua) use `~='; several
Pascal-based languages use `<>'; Oberon, Modula2, and Modula3 use `#'.

Long ago when I started uCore the same discussion (!= vs ~=) lived but with a twist.... cause the "~" is a dead key on a danish keyboard (and lot of other European keyboard layouts) so is was a pain in the *** to use it compared to the alternatives. But we learned to live with it and when my staff ask "WHY???" - I just say "It's a funky brazillian thing - just think of it as a exotic twist to a boring life in the cold north! :-))"

/Erik