Subscribe
Subscribe
Re: Question about get/put REPL vs executing a file
Got it - I'll just use non-transient symbols like 'A instead :) Thanks Alex! Kashyap On Sat, Sep 23, 2023 at 12:02 PM Alexander Burger wrote: > Hi Kashyap, > > > kashyap@CPC-ckk-S75640M:~$ cat a.l > > (de add (N D) > >(put 'STORE N D) ) > > (add "A" 10) > > (add "B" 20) > > (prinl (get 'STORE "A")) > > (prinl (get 'STORE "B")) > > kashyap@CPC-ckk-S75640M:~$ pil a.l > > 10 > > 20 > > : (get 'STORE "A") > > -> NIL > > : version > > -> 274406 > > > > Shouldn't I get 10 as a result of (get 'STORE "A") from the REPL? > > No, because transient symbols like "A" and "B" have a file-local scope > (just > like symbols in the 'private' namespace). > > Property functions like 'put' and 'get' access the value by the symbol > itself > (using pointer equality, '=='), not by the name. So the "A" in > >(get 'STORE "A") > > in the REPL *after* the file is loaded is another symbol than the "A" in > the > file *while* it is loaded. > > ☺/ A!ex > > -- > UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe >
Re: Question about get/put REPL vs executing a file
Hi Kashyap, > kashyap@CPC-ckk-S75640M:~$ cat a.l > (de add (N D) >(put 'STORE N D) ) > (add "A" 10) > (add "B" 20) > (prinl (get 'STORE "A")) > (prinl (get 'STORE "B")) > kashyap@CPC-ckk-S75640M:~$ pil a.l > 10 > 20 > : (get 'STORE "A") > -> NIL > : version > -> 274406 > > Shouldn't I get 10 as a result of (get 'STORE "A") from the REPL? No, because transient symbols like "A" and "B" have a file-local scope (just like symbols in the 'private' namespace). Property functions like 'put' and 'get' access the value by the symbol itself (using pointer equality, '=='), not by the name. So the "A" in (get 'STORE "A") in the REPL *after* the file is loaded is another symbol than the "A" in the file *while* it is loaded. ☺/ A!ex -- UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
Question about get/put REPL vs executing a file
Hi Alex et al, Following illustrates the inconsistent behaviour of get/put between file and REPL. kashyap@CPC-ckk-S75640M:~$ cat a.l (de add (N D) (put 'STORE N D) ) (add "A" 10) (add "B" 20) (prinl (get 'STORE "A")) (prinl (get 'STORE "B")) kashyap@CPC-ckk-S75640M:~$ pil a.l 10 20 : (get 'STORE "A") -> NIL : version -> 274406 Shouldn't I get 10 as a result of (get 'STORE "A") from the REPL? Regards, Kashyap