where is the value which is assigned by setq to a symbol?

Pondering the philosophy behind the language
Locked
lyl
Posts: 44
Joined: Sun Mar 25, 2018 5:00 am

where is the value which is assigned by setq to a symbol?

Post by lyl »

I wonder where or how I can get the value which is assign by setq to a symbol like this:

Code: Select all

(setq 'f 100)
'f ;;-> f
''f ;;->'f
How can I get the value 100?

cameyo
Posts: 183
Joined: Sun Mar 27, 2011 3:07 pm
Location: Italy
Contact:

Re: where is the value which is assigned by setq to a symbol?

Post by cameyo »

Maybe you can define 'f in a different way:

Code: Select all

(set (sym {'f}) 100)
;-> 100
(eval (sym {'f}))
;-> 100
or

Code: Select all

(set (sym {''f}) 2)
;-> 2
(eval (sym {''f}))
;-> 2
cameyo

fdb
Posts: 66
Joined: Sat Nov 09, 2013 8:49 pm

Re: where is the value which is assigned by setq to a symbol?

Post by fdb »

Wel you either do

Code: Select all

> (set 'f 100)
100
> f
100
Or you do

Code: Select all

> (setq f 100)
100
> f
100
With set you have to quote because set evaluates its arguments, setq doesn't.

lyl
Posts: 44
Joined: Sun Mar 25, 2018 5:00 am

Re: where is the value which is assigned by setq to a symbol?

Post by lyl »

Many thanks! But where is the value stored in the expression "(setq 'f 100)"

TedWalther
Posts: 608
Joined: Mon Feb 05, 2007 1:04 am
Location: Abbotsford, BC
Contact:

Re: where is the value which is assigned by setq to a symbol?

Post by TedWalther »

Whereever it is stored, if anywhere, it is immediately deleted on returning from setq. Why? Because 'f is the same as (quote f) And setting a value to a quote cell doesn't bind it to a symbol... so the ORO memory manager (should) just toss it.
Cavemen in bearskins invaded the ivory towers of Artificial Intelligence. Nine months later, they left with a baby named newLISP. The women of the ivory towers wept and wailed. "Abomination!" they cried.

Locked