Newsgroups: comp.lang.scheme
Path: cantaloupe.srv.cs.cmu.edu!das-news2.harvard.edu!news2.near.net!howland.reston.ans.net!gatech!udel!princeton!news.princeton.edu!blume
From: blume@dynamic.cs.princeton.edu (Matthias Blume)
Subject: Re: bit manipulation operators in scheme?
In-Reply-To: eichin@cygnus.com's message of 11 Nov 1994 17:43:06 -0500
Message-ID: <BLUME.94Nov12114556@dynamic.cs.princeton.edu>
Originator: news@hedgehog.Princeton.EDU
Sender: news@Princeton.EDU (USENET News System)
Nntp-Posting-Host: dynamic.cs.princeton.edu
Organization: Princeton University
References: <3a0s1q$ej1@tweedledumb.cygnus.com>
Date: Sat, 12 Nov 1994 16:45:56 GMT
Lines: 37

In article <3a0s1q$ej1@tweedledumb.cygnus.com> eichin@cygnus.com (Mark Eichin) writes:

   I noticed that the FAQ and the R4RS don't mention bit manipulation
   operators at all. Are there common extensions to do this, or do people
   just not do that in scheme?

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

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.

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:

	- storage management
	- implementation of BIGNUMS
	- operating system interface (O_NONBLOCK...)

This is a total of less than 60 occurences in 15,000 lines of C code,
restricted to 3 or 4 files (of more than 70).

So again:  why do you need bit-operations in Scheme?

   This is certainly something C has plenty of low-level operators for,
   but I haven't found *any* operators for it in scheme. Is there a
   rationale behind the lack? If so, where might it be documented?

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

--
-Matthias
