CoCreate User Forum  

Go Back   CoCreate User Forum > Support > Customization

Reply
 
Thread Tools Search this Thread Rate Thread Display Modes
  #1  
Old 06-28-2004, 09:40 PM
robin robin is offline
Junior Member
 
Join Date: Jun 2004
Posts: 12
LIsp

what is diffrent between setq and setf (details) ?
Reply With Quote
  #2  
Old 06-29-2004, 07:44 AM
John Scheffel's Avatar
John Scheffel John Scheffel is offline
Administrator
 
Join Date: Sep 2002
Location: San Jose, CA
Posts: 1,288
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
Reply With Quote
  #3  
Old 06-29-2004, 10:59 AM
clausb's Avatar
clausb clausb is offline
Registered User
 
Join Date: Nov 2002
Posts: 1,168
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)
Note that the first argument isn't really an ordinary variable, but rather the description (as a LISP form) of a place where the value is to be written to. http://www.supelec.fr/docs/cltl/clm/node80.html lists which kind of forms can be used with setf.

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
Reply With Quote
  #4  
Old 06-29-2004, 10:41 PM
robin robin is offline
Junior Member
 
Join Date: Jun 2004
Posts: 12
Thanks!!

Thanks Calus & Jones...
Both of your replies are quite useful to me... in short i have concluded

Setq=set Quantity
Setf= set Field
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -8. The time now is 08:34 AM.



Hosted by SureServer    Forums   Modeling FAQ   Macro Site   Vendor/Contractors   Software Resellers   CoCreate   Gallery   Home   Board Members   Regional User Groups  By-Laws  

Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.