Newsgroups: comp.lang.scheme
Path: cantaloupe.srv.cs.cmu.edu!das-news2.harvard.edu!news2.near.net!howland.reston.ans.net!ix.netcom.com!netcom.com!bakul
From: bakul@netcom.com (Bakul Shah)
Subject: Re: bit manipulation operators in scheme?
Message-ID: <bakulCz7zK8.Cw@netcom.com>
Organization: NETCOM On-line Communication Services (408 261-4700 guest)
References: <3a0s1q$ej1@tweedledumb.cygnus.com> <BLUME.94Nov12114556@dynamic.cs.princeton.edu>
Date: Sun, 13 Nov 1994 19:02:31 GMT
Lines: 39

blume@dynamic.cs.princeton.edu (Matthias Blume) writes:

>Can someone quickly remind me why one would need bit-operations in Scheme?
>I hardly ever use them in C!

You'd need them for *efficient* operations on sets of small
integers.  Quite a few problems can be transformed into
operations on integer sets.  Logic minimization, Warshall's
algorithm (parsing), representation of certain two person games,
to name a few places where one can use sets.

In fact, Scheme or any language with bignums is ideal for using
integers to represent integer-sets because you are not limited to
sets of <= N integers where the machine word size is 2^N.

>It is certainly not useful to have `bit'-operations applicable to
>Scheme numbers (integers included), because there is nothing said
>about how these numbers are represented as bits.  Bit-operations would
>be highly non-portable.

Only in an ideal world.  How many people use 1's complement
machines these days?  Other than that it is easy to define bit
operations portably.

>To illustrate my point about the small frequency in which these
>operations are needed *in C* I just grep'ed the entire C source code
>of VSCM for bitwise &|^~<<>> and it turns out that all occurences are
>in one of these areas:

VSCM is a fine program but it is unlikely to cover the universe
of problems tackled by the hordes of C (or other language
speaking) barbarians.

>Perhaps the rationale can be given by (not) answering my question.  Or
>-- even better -- by un-asking it.  MU.

Moo!

Just another polyglot barbarian
