guile-devel
[Top][All Lists]
Advanced

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

Re: [PATCH] Bring `bitwise-copy-bit' behavior back in line with R6RS.


From: Mark H Weaver
Subject: Re: [PATCH] Bring `bitwise-copy-bit' behavior back in line with R6RS.
Date: Mon, 18 Sep 2017 02:30:25 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux)

Mark H Weaver <address@hidden> writes:

> Julian Graham <address@hidden> writes:
>
>> It looks like there was a subtle but significant regression introduced
>> to the behavior of `bitwise-copy-bit' in `(rnrs arithmetic bitwise)'
>> back in 93da406f33.
>>
>> R6RS says [0] that function (with arguments EI1, EI2, EI3) should
>> transfer the EI2th bit from EI3 to EI1, but Guile's implementation was
>> always reading the 0th bit from EI3.
>
> I was puzzled by this, because the same specification also states that
> "ei3 must be either 0 or 1",

Also note that the same specification also states that the result of
(bitwise-copy-bit ei1 ei2 ei3) is the same as the result of:

  (let* ((mask (bitwise-arithmetic-shift-left 1 ei2)))
    (bitwise-if mask
                (bitwise-arithmetic-shift-left ei3 ei2)
                ei1))

and this unambiguously required that the 0th bit of 'ei3' is the bit
that is copied.

      Mark



reply via email to

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