[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Bitwise logical operators
Well, I can't remember what has been proposed and discussed regarding
bitwise (logical) operators on integers, so sorry if this is
redundant. I was a little surprised they didn't appear anywhere in
Bert and Norman's list (unless they come under the "bit vectors"
heading) since it was my feeling that they ought at least to make it
to triage class 2.
I think the following proposal is on the table:
logand, logior, logxor, lognot, ash
Bitwise logical operators, as in Common Lisp (I think we all
know what they're supposed to do so I won't go into it). They
operate on integers.
No machine dependencies here; the semantics isn't sensitive to word
size or integer representation. I'll supply portable definitions on
I've heard no objections to these, not even on the grounds that the
language is getting too clutterred. Please speak up or I'll suggest
that they go into triage class 1.
Having said that there has been no objection, let me disrupt this
status quo and suggest some different names:
bitwise-and, bitwise-ior, bitwise-xor, bitwise-not, arithmetic-shift
These are what Richard Kelsey calls them. I've been using these names
for about a year now and like them better than the Common Lisp names.
They're more descriptive, and I would expect them to be easier for
beginners to cope with. And calling them "logical" implies that other
operations on integers are illogical.
My feeling is that in order for them to be efficient enough for
practical use, they have to be implemented at the machine level; a
"yellow pages" definition doesn't do the trick.
Any opinions on logcount (bit-count) and integer-length?