On Sat, Mar 22, 2008 at 12:17 PM, Robert Dodier <robert.dodier at gmail.com> wrote:
> > On Wed, Mar 19, 2008 at 5:39 PM, van Nek <van.nek at arcor.de> wrote:
> > > bit_and(x) => x...
> > > Should these be valid for all x and foo, or do they require that
> > > x is declared as integer and foo is declared as integervalued?
> ... I would rather see simplifications of bitwise operators carried
> out only if the argument is is known by Maxima to be an integer
> (i.e. a literal integer or a symbol or function declared to be integral
> or an expression which is demonstrably integral).
Interesting, Robert. In past discussions, I get the impression that
I've been the one insisting on rigor, and you've been encouraging ease
of use.
One of the things that makes Maxima (relatively) easy to use is
precisely the lack of declarations. We don't require the user to
declare x as a non-zero real to allow 1/x, and he can even substitute
false or matrix([2,3],[4,6]) for x later.
Not allowing bit_and(x,x) => x and bit_and(x,bit_not(x)) => 0 and
bit_or(x,bit_not(x)) => -1 without explicit declarations of x as an
integer would make using bit_xxx far more clumsy, and I'm not sure it
would prevent any real errors.
Just to surprise you more, I might even think that treating false as 0
and true as -1 in the context of bit operations makes sense, e.g.
bit_and(23,true) => 23; bit_not(true) => 0.
-s