[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: __bshr vs __bshl
- From: tobias@...
- Date: Sun, 08 Apr 2018 09:32:27 +0200
Not everything that uses << or >> is performing something analogous to
a symmetric bit shift.
C++ developers, for example, use it to mean insertion and extraction.
I don't know off the top of my head if there are any popular Lua
libraries that use the operators for asymmetric behaviors, but it
wouldn't surprise me if LPeg were among them. (I haven't actually used
it!)
When implementing Set functionality you can reuse operators nicely
[1,2,3,4] | [5,6,2,3] = [1,2,3,4,5,6] (union)
[1,2,3,4] & [5,6,2,3] = [2,3] (intersection)
If you take the metamethods out of math context it's really nice that all
of them are available.
-tobbik