#1
|
|||
|
|||
LIsp
what is diffrent between setq and setf (details) ?
|
#2
|
||||
|
||||
You can find an online LISP manual at:
http://www.supelec.fr/docs/cltl/clm/node1.html This page discusses setf and setq. The short answer seems to be that setq can assign only to symbols(variables), but setf can assign to other data types. I believe you can use setf anywhere you can use setq, so you don't see setq used much.
__________________
John Scheffel |
#3
|
||||
|
||||
I'm glad that someone asked since this finally allowed me to refresh my memory about setf and setq. Every once in a while, I look it up, and then after a few weeks I forget about it again 8-)
setf is a macro which builds on setq, but also allows to do funky stuff like this: Code:
(setf (fifth somelist) 42) In the majority of cases, this special evaluation isn't needed, so you're probably slightly better off (in terms of performance) by using setq. If you get it wrong, LISP will kindly remind you, so you can then still use setf instead when required. Claus |
#4
|
|||
|
|||
Thanks!!
Thanks Calus & Jones...
Both of your replies are quite useful to me... in short i have concluded Setq=set Quantity Setf= set Field |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
|
|