Page 1 of 1
where is the value which is assigned by setq to a symbol?
Posted: Thu Jul 23, 2020 6:49 am
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?
Re: where is the value which is assigned by setq to a symbol?
Posted: Thu Jul 23, 2020 3:21 pm
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
Re: where is the value which is assigned by setq to a symbol?
Posted: Thu Jul 23, 2020 7:11 pm
by fdb
Wel you either do
Or you do
With set you have to quote because set evaluates its arguments, setq doesn't.
Re: where is the value which is assigned by setq to a symbol?
Posted: Fri Jul 24, 2020 7:50 am
by lyl
Many thanks! But where is the value stored in the expression "(setq 'f 100)"
Re: where is the value which is assigned by setq to a symbol?
Posted: Sat Jul 25, 2020 10:42 pm
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.