← Back to context

Comment by kibwen

17 hours ago

Please don't, inscrutable bitwise operators are an accident of the past even in systems languages, let alone in a scripting language. I'm not against infix operators for bitwise operations, just please spell them out with keywords rather than giving them sigils.

Likewise, going from `and` and `or` to `&&` and `||` would be a dispiriting regression. This is something that Zig got right.

What kind of person understands and needs bitwise operators but can't easily remember & | ~ and the arrows for shift? It's very little information.

The part I'd call a hassle is the different kinds of right shift but you have that same hassle if you use keywords.

I like using the and/or keywords for logical operations. Now let's make bitwise look significantly different from that.

  • It's not about having to remember them, it's that you shouldn't waste these short single symbols on operations that are only rarely used.

    This stuff (especially the ternary) are a step backwards. There is just no reason to waste | on a bitwise or that gets used at 1% of the frequency of the standard or. In the future you might have a better use for it (pipeline syntax, sum or union types come to mind in other languages).

    I dislike basically everything about these syntax extensions.

    • Lua is very unlikely to want to add newer/less-common syntax with special symbols.

      Also a syntax for types can repurpose most symbols without being ambiguous.

      And you can overload the bitwise operators. You can configure __bor to give you pipelining right now.

I'm going to disagree only because one of the primary use cases for LuaJIT is interop with C and I think there's a case for making the ergonomics match.