newLISP Fan Club

Forum => newLISP in the real world => Topic started by: newBert on March 04, 2019, 05:30:46 AM

Title: let and letn
Post by: newBert on March 04, 2019, 05:30:46 AM
I don't understand why letn isn't required here, or why let doesn't cause an error:
(let (a 1 b 2 c 3 d '(4 5 6 7) e (flat (list a b c d)))
  (println (list a b c d e)))
;−> (1 2 3 (4 5 6 7) (1 2 3 4 5 6 7))
Title: Re: let and letn
Post by: rrq on March 05, 2019, 12:17:22 AM
Hmm. I get (1 2 3 (4 5 6 7) (nil nil nil nil)) as I would expect.
Title: Re: let and letn
Post by: cameyo on March 05, 2019, 03:27:08 AM
I get:
(1 2 3 (4 5 6 7) (nil nil nil nil))
with newLISP 10.7.5 and 10.7.4 on windows 10.

cameyo
Title: Re: let and letn
Post by: rickyboy on March 05, 2019, 07:44:29 AM
I think newBert just had a polluted outer environment.  newBert, try running that code with a freshly started newlisp.
Title: Re: let and letn [resolved]
Post by: newBert on March 07, 2019, 09:33:47 AM
Indeed, I've just tried again now, in a new NewLISP session, and I get the expected result: (1 2 3 (4 5 6 7) (nil nil nil nil)). I'm reassured :). Thank you , RalphRonnquist, Cameyo and Rickyboy for your replies and advice.

I don't know what could have happened... I probably forgot NewLISP has no lexical scoping by default.