chicken-hackers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Chicken-hackers] bit-set? is inconsistently specified


From: Thomas Bushnell BSG
Subject: [Chicken-hackers] bit-set? is inconsistently specified
Date: Mon, 03 Aug 2009 12:33:17 -0700

The chicken scheme library unit defines bit-set? as

        [procedure] (bit-set? N INDEX)
        Returns #t if the bit at the position INDEX in the integer N is
        set,   or #f otherwise. The rightmost/least-significant bit is
        bit 0.

Alas, this is inconsistent with srfi-60, which has the parameters in the
opposite order:

        Function: logbit? index n
        Function: bit-set? index n
                (logbit? index n) == (logtest (expt 2 index) n)
                
This can produce subtle and hard-to-find bugs.  Notice that bit-set? is
optimized by extended-bindings declarations...

I think the best solution here is to decide to adopt the srfi-60 meaning
(it is implausibly ludicrous in the extreme to go the other way, in my
opinion).

At the same time, we don't want existing code that uses the backwards
definition to get broken.  I think the right solution is simply to drop
bit-set? entirely from the library unit.

Thomas







reply via email to

[Prev in Thread] Current Thread [Next in Thread]