You are not logged in.

#1 2006-07-13 02:57:15

syamajala
Member
From: here, there, everywhere
Registered: 2005-01-25
Posts: 617
Website

lisp properties

i don't get properties in lisp. i did

(setq stuff '((color red) (size big) (shape square)) 
(get 'stuff 'color) 

but it returns nil. i thought it was supposed to return red. i know get returns nil if no property with the given name exists, but when i type stuff it shows the association list. Anyone know whats wrong?

Offline

#2 2006-07-13 03:03:33

pauldonnelly
Member
Registered: 2006-06-19
Posts: 776

Re: lisp properties

EDIT:
Sorry, I was looking at an out of date reference. I think you want something like (setf (get 'stuff 'color) 'red).

Dang, when I was typing that I kept hitting vi keys and making who knows what happen. I'm not used to typing code in a web browser.

Offline

#3 2006-07-13 06:39:27

user
Member
Registered: 2006-03-29
Posts: 465

Re: lisp properties

http://www.cliki.net/hyperdoc

hope it help you & me.


I removed my sig, cause i select the flag, the flag often the target of enemy.

SAR brain-tumor
[img]http://img91.imageshack.us/img91/460/cellphonethumb0ff.jpg[/img]

Offline

#4 2006-07-13 07:48:35

pauldonnelly
Member
Registered: 2006-06-19
Posts: 776

Re: lisp properties

Also, the appendix in Common Lisp the Language 2 (available online) is a godsend.

What are you using properties for anyway? They don't seem to useful to me.

Offline

#5 2006-07-13 12:33:19

syamajala
Member
From: here, there, everywhere
Registered: 2005-01-25
Posts: 617
Website

Re: lisp properties

no reason, and i thought (setf (get 'stuff 'color) 'red) was for changing the property color of the symbol stuff to red from something else. I have common lisp the first edition but its still shrink wrapped so i didn't open it because i also found Lisp second edition by patrick henry winston and berthold klaus paul horn.

Offline

#6 2006-07-13 21:45:00

pauldonnelly
Member
Registered: 2006-06-19
Posts: 776

Re: lisp properties

syamajala wrote:

no reason, and i thought (setf (get 'stuff 'color) 'red) was for changing the property color of the symbol stuff to red from something else

It's for both changing it and setting it in the first place. Apparently it used to be done with PUT, but that was removed in favor of SETF.

Offline

Board footer

Powered by FluxBB