[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#35546: 27.0.50; setf return value for new alist entries is wrong
From: |
npostavs |
Subject: |
bug#35546: 27.0.50; setf return value for new alist entries is wrong |
Date: |
Tue, 07 May 2019 10:58:13 -0400 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/26.1.92 (windows-nt) |
Michael Heerdegen <michael_heerdegen@web.de> writes:
> struggling with 'logand', because I don't understand what it is doing.
> Not only that "it should arguably fail when trying to set a value
> outside of the mask" as described in the file header, I also don't see
> how the used formula makes more sense than setting the place to just V.
I think the rationale goes like this:
Suppose you want to *get* the bottom 4 bits of PLACE, you do
(logand PLACE #x0F)
;; Example:
(let ((var #xABCD))
(logand var #x0F)) ;=> #xD
Suppose you want to *set* the bottom 4 bits of PLACE, you do
(setf (logand PLACE #x0F) VALUE)
;; Example:
(let ((var #xABCD))
(setf (logand var #x0F) 9)
var) ;=> #xABC9