Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

LISP: A dynamic car

Name: Anonymous 2012-01-30 20:27

I have a complex list of lists and want something to check the second element of every list of the list in the loop, any supported features like this?

Name: Anonymous 2012-02-13 22:19

>>46
When you write (setf (car x) y), this is what it doesn't do:

(let ((z (car x)))
  (setf z y))


z just contains the value of (car x), not a pointer to it. So (setf z y) wouldn't actually modify the cons cell, and the code wouldn't work.

Instead, when setf sees the call to car, it passes the cons cell to rplaca, which modifies the car.

defsetf tells setf which function you want it to call when you have (setf (bref x y) z). In the code you posted, that will expand to (setf (aref x y) z), which well then expand to whatever code setf was told to use to set an aref form.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List