On Tue, Feb 27, 2007 at 06:31:31PM +0000, Smylers wrote:
> Geoffrey Broadwell writes:
> > Perhaps having both +> and ?> operators?  Since "coerce to boolean and
> > then right shift" is meaningless, ...
> It's useless, rather than meaningless; you've neatly defined what the
> meaning of that (useless) operator would be.
[ ... ]
> > this seems ripe to DWIM.
> But "DWIM" is the meaning you previously defined, surely?
> > (For me, DWIM here means "+> does high bit extension, ?> does zero
> > fill".)
> Why?  You think that somebody not knowing about this operator would
> correctly infer its existence from other operators?  Even if somebody
> guessed that both operators exist it looks pretty arbitrary which is
> which.

While I tend somewhat to agree that this level of bit
manipulation is not common enough to justify warping the
language; I disagree that the choice of meaning between +>
and ?> is arbitrary and not subject to inference.  The normal
assembler opcodes for the two forms of right shift are LRS
(logical right shift) and ARS (arithmetic right shift) with some
variation in spelling for different hardware architectures.
The arithmetic variant propagates the sign bit; the boolean
variant inserts zeros.  A "sign bit" is an integer property
that has no meaning in boolean context.  It would be hard to
find any rationale for reversing the meaning of the two.


Reply via email to