unexpected setq behavior with contexts ?

Started by dave_f, September 21, 2008, 09:31:17 AM

Previous topic - Next topic

dave_f

In the code below, the version with "set" in line 5 produces (Second First) as a list of contexts.  This was what I expected.  



The version with "setq" produced (First First), which was a surprise.  Why is this?



thanks a lot,

dave_f

     newLISP v.9.9.2 , Mac OS 10.5.5 Intel


(context 'CTX)
(context 'MAIN)
(setq ctx-names '(First Second))
(dolist (ctx-name ctx-names)
  (set 'new-ctx (new CTX ctx-name) ) ; this works as I expected
;  (setq new-ctx (new CTX ctx-name))  ; this does not work as I expected
(push new-ctx contexts)  )
(println "context list is " contexts)

m i c h a e l

#1
Dave,



This is because the second time through the iteration of dolist, ctx-name will be the context First:


> (define CTX:CTX)
nil
> (setq new-ctx (new CTX 'First))
First
> new-ctx
First
> (context? new-ctx)
true
> (setq new-ctx (new CTX 'Second))
Second
> new-ctx
First
> _


m i c h a e l

Lutz

#2
It should produce (Second First) both times and does it in 9.4.5



This is a bug introduced in 9.9.2 and is fixed in 9.9.4.