Subject: [clisp-list] setq vs setf

From: "Justice, Randy -CONT" <[email-masked]>
Date: Fri, 9 Feb 2001 12:12:26 -0600

What is the difference between setq and setf?

Or can one explain...

SETQ: (AREF TXY TXY_X TXY_Y) is not a symbol

on line
(setq (aref txy txy_x txy_y) (+ (aref txy txy_x txy_y) delta))

where 

(setf (aref txy txy_x txy_y) (+ (aref txy txy_x txy_y) delta))

works?

I use setq in other places in the same function and it works fine.

Thanks in advance

Randy

---

From: Sam Steingold <[email-masked]>
Date: 09 Feb 2001 14:00:10 -0500

> * In message <[email-masked]>
> * On the subject of "[clisp-list] setq vs setf"
> * Sent on Fri, 9 Feb 2001 12:12:26 -0600
> * Honorable "Justice, Randy -CONT" <[email-masked]> writes:
>

`setq' works only on symbols, `setf' works on places too.

> (macroexpand '(setf x 10))
(setq x 10) ;
t

this tells you that `setf' is the same as `setq' on symbols.

please read

http://www.lisp.org/HyperSpec/Body/mac_setfcm_psetf.html
http://www.lisp.org/HyperSpec/Body/spefor_setq.html
http://www.lisp.org/HyperSpec/Body/mac_define-setf-expander.html
http://www.lisp.org/HyperSpec/Body/mac_defsetf.html
http://www.lisp.org/HyperSpec/Body/mac_defun.html

you might find 
http://sourcery.naggum.no/emacs/hyperspec.el
useful.

note that this is a general Common Lisp question.
you would have received much more help if you asked it on
news:comp.lang.lisp. 

-- 
Sam Steingold (http://www.podval.org/~sds)
Support Israel's right to defend herself! <http://www.i-charity.com/go/israel>
Read what the Arab leaders say to their people on <http://www.memri.org/>
Of course, I haven't tried it. But it will work. [Isaak Asimov]