Newsgroups: comp.lang.scheme
Path: cantaloupe.srv.cs.cmu.edu!das-news2.harvard.edu!news2.near.net!news.mathworks.com!hookup!news.sprintlink.net!siemens!princeton!news.princeton.edu!blume
From: blume@dynamic.cs.princeton.edu (Matthias Blume)
Subject: Re: bit manipulation operators in scheme?
In-Reply-To: tammet@cs.chalmers.se's message of 13 Nov 1994 16:23:13 GMT
Message-ID: <BLUME.94Nov13134414@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>
	<BLUME.94Nov12114556@dynamic.cs.princeton.edu>
	<3a5ehh$ao4@nyheter.chalmers.se>
Date: Sun, 13 Nov 1994 18:44:14 GMT
Lines: 36


   I asked:

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

In article <3a5ehh$ao4@nyheter.chalmers.se> tammet@cs.chalmers.se
(Tanel Tammet) answers:

   I can. Differently from C, we do not have structures in scheme
   (I guess you use structures in C, do you?).

Yes, I do. (After all, I don't have heterogeneous lists and vectors in
C. -- Just kidding. :)

   Suppose you are essentially using structures consisting of
   20 boolean fields.

Why would I do *that*?  (BTW, this is the question I was asking in the
first place.  I know that bit-manipulations can be used to
(efficiently (?)) simulate strings of booleans.)

   Then you might come to this incredibly
   clever idea ;-) of encoding these as bits in an integer, instead
   of taking a 20-element list or a vector to represent a structure.

   In addition to booleans you might want the same when you have
   very small ints or small enumeration types as fields.

This looks like a bunch of micro-optimizations to me.  Not worth it
most of the time in most of the applications for Scheme (IMO).
(Let's not get into this ``I care about efficiency -- I know you
don't...'' discussion!)

--
-Matthias
