[comp.lang.modula2] Bit shifting operations

sullivan@marge.math.binghamton.edu (fred sullivan) (08/26/87)

>Supposedly, Modula-2 is a good systems programming language; but it
>has no native bit-shifting operations.  Aren't bit-shifting 
>operations important tools for EFFICIENT systems programming?
>Turbo Pascal and "C" have native bit-shifting operations, but not
>Modula-2.  Was this omission a wise design decision?  I would like
>to read some opinions on this question.

I agree that I sometimes wish that they existed.  On the other hand, bit
operations are inherently machine dependent.  Since such things are
going to vary from machine to machine anyway, perhaps Prof. Wirth decided
that it should be up to Modula implementors for various machines to include
shifts or not.  At least one compiler (the Powell compiler for Ultrix)
includes a bit manipulation module which implements shifts as in-line code
(although they appear to the user to be procedures).  At any rate, most
things (e.g. setting up masks) can be done effiently with Intsets anyway.

Fred Sullivan
Department of Mathematical Sciences
State University of New York at Binghamton
Binghamton, New York  13903
Email: sullivan@marge.math.binghamton.edu

soper@encore.UUCP (Pete Soper) (08/27/87)

In article <669@bingvaxu.cc.binghamton.edu>
   sullivan@marge.math.binghamton.edu (fred sullivan) writes:

>>Supposedly, Modula-2 is a good systems programming language; but it
>>has no native bit-shifting operations.  Aren't bit-shifting 

>operations are inherently machine dependent.  Since such things are
>going to vary from machine to machine anyway, perhaps Prof. Wirth decided
>that it should be up to Modula implementors for various machines to include
>shifts or not.  At least one compiler (the Powell compiler for Ultrix)

Actually, Prof. Wirth provided a slew of extremely machine
dependent procedures in module SYSTEM for his single pass compiler. These
procs expand to inline code and are extremely efficient. They include both
arithmetic and logical shifts and a rotate function. Amazingly, though,
NEW AND DISPOSE as predefined procedures are absent and each port involves
implementing them.
-- 
Pete Soper, Encore Computer Corp
uucp: {necntc,talcott,ihnp4,decvax,allegra}!encore!soper