[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: bit-ops
- From: Doug Rogers <rogers@...>
- Date: Mon, 8 Nov 2004 20:43:51 -0500 (EST)
On Sun, 7 Nov 2004, Antero Vipunen wrote:
> Is there any specific reason for having not '~' but '#' as
> unary-bitwise-not symbol?
It is certainly a matter of taste. I would have preferred to use the C
notation throughout, but since '^' was taken I had to come up with a
replacement for XOR, and what is bitwise negation but an XOR of all the
bits in the word with 1? Since '~' is used in '~=' in Lua, meaning
logical negation, I thought '#' a better fit. Originally I used '~',
just as you suggest.
It's fairly easy to change. I did not attempt to understand the Lua
internals much when I wrote the patch. I just copied the patterns that I
saw and added a single conversion routine for hexadecimal.
I was hoping for some input from others. I discussed it with Asko and at
least one other person at the time. I considered a using a two-
character token: a 'bit-wise' indicator followed by the operator.
So 'a#|b' for 'bitwise or', 'a#^b' for 'bitwise XOR'.
If there's a consensus on what would be better, I have no problem changing
it. I'd love to have it be part of the language even, but I understand
that my domain (communications) does not have the presence as other
domains, such as game scripting, where bitwise operations are less common.
Doug Rogers - ICI - V:703.893.2007x220 www.innocon.com