newLISP Fan Club

Forum => Whither newLISP? => Topic started by: lyl on July 22, 2020, 11:49:18 PM

Title: where is the value which is assigned by setq to a symbol?
Post by: lyl on July 22, 2020, 11:49:18 PM
I wonder where or how I can get the value which is assign by setq to a symbol like this:
(setq 'f 100)
'f ;;-> f
''f ;;->'f

How can I get the value 100?
Title: Re: where is the value which is assigned by setq to a symbol?
Post by: cameyo on July 23, 2020, 08:21:22 AM
Maybe you can define 'f in a different way:
(set (sym {'f}) 100)
;-> 100
(eval (sym {'f}))
;-> 100

or
(set (sym {''f}) 2)
;-> 2
(eval (sym {''f}))
;-> 2
cameyo
Title: Re: where is the value which is assigned by setq to a symbol?
Post by: fdb on July 23, 2020, 12:11:14 PM
Wel you either do

> (set 'f 100)
100
> f
100

Or you do
> (setq f 100)
100
> f
100

With set you have to quote because set evaluates its arguments, setq doesn't.
Title: Re: where is the value which is assigned by setq to a symbol?
Post by: lyl on July 24, 2020, 12:50:16 AM
Many thanks! But where is the value stored in the expression "(setq 'f 100)"
Title: Re: where is the value which is assigned by setq to a symbol?
Post by: TedWalther on July 25, 2020, 03:42:45 PM
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.