The Liberating Experience of Common Lisp
ds9soft.com125 pointsby _19qg125 comments
Я твой слуга (Ja tvoi sluga) (I'm your slave)
Я твой работник (Ja tvoi rabotnik) (I'm your worker) (defun foo (a)
[1, 2, (+ 1 a)])
Common Lisp in general assumes that in (defun foo (a)
'(1 2 3))
it is undefined what exact effects the attempts to modify the quoted list (1 2 3) has. Additionally the elements are not evaluated. We have to assume that the quoted list (1 2 3) is a literal constant. * (let ((a '(1 2 3))) (setf (car a) 4) a)
; in: LET ((A '(1 2 3)))
; (SETF (CAR A) 4)
;
; caught WARNING:
; Destructive function SB-KERNEL:%RPLACA called on constant data: (1 2 3)
; See also:
; The ANSI Standard, Special Operator QUOTE
; The ANSI Standard, Section 3.7.1
;
; compilation unit finished
; caught 1 WARNING condition
(4 2 3)
* attempts to modify literal constants may modify coalesced lists (defun foo ()
(let ((a '(1 2 3))
(b '(1 2 3)))
(setf (car a) 10)
(eql (car a) (car b))))
In above function, a file compiler might detect that similar lists are used and allocate only one object for both variables.
1) place the cursor on the left parenthesis of the form
2) type paredit-wrap-round: M-(
3) type: if flag
Doesn't appear to be overly complex.