lua-users home
lua-l archive

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


On Thu, Mar 7, 2013 at 9:32 AM, Gavin Kistner <phrogz@me.com> wrote:
> On Mar 6, 2013, at 10:01 PM, Miles Bader <miles@gnu.org> wrote:
>> Philippe Lhoste <PhiLho@GMX.net> writes:
>>> Funnily, I rarely see complains about using -- as in-line comment
>>> symbol, or .. as string concatenation symbol.
>>
>> I find I use comments and string-concatenation so often they quickly
>> became second-nature (Lua's comment syntax is also rather pretty,
>> which is a nice plus).  For whatever reason, that doesn't seem to be
>> true of inequality, at least for me.
>
> This is also true for me, and I think it may have to do with the mismatch between unary negation and not equals.
>
> In C/JavaScript/Java/Ruby/Io you use != for "not equals".
> In C/JavaScript/Java/Ruby you use !a for "not a".
> There is a nice mental symmetry here. The English word "not" and the programming "!" operators are equivalent.
>
> Ruby and Lua and Io use "not" for logical negation. (Ruby allows both "not" and "!" with different precedence.)
>
> But Lua is the only language I personally know that uses "~=" for not equals. It especially conflicts mentally for me with the Ruby "=~" operator which is used generally for pattern matching.
>
> Python's "<>" for inequality is also strange to me, but not as strange as "~=".
>
>
>

"<>" is different but makes perfect sense from a logical standpoint:
"less than or greater than", i.e. not equal to.

Personally I don't mind using ~= in Lua, but I feel like accepting
both ~= and != would be great for people who have a hard time typing
~, and not be significant bloat (a single additional 'if' statement?).

-- 
Sent from my Game Boy.