let and letn

Started by newBert, March 04, 2019, 05:30:46 AM

Previous topic - Next topic

newBert

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))
<r><I>>Bertrand<e></e></I> − <COLOR color=\"#808080\">><B>newLISP<e></e></B> v.10.7.6 64-bit <B>>on Linux<e></e></B> (<I>>Linux Mint 20.1<e></e></I>)<e></e></COLOR></r>

rrq

#1
Hmm. I get (1 2 3 (4 5 6 7) (nil nil nil nil)) as I would expect.

cameyo

#2
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

rickyboy

#3
I think newBert just had a polluted outer environment.  newBert, try running that code with a freshly started newlisp.
(λx. x x) (λx. x x)

newBert

#4
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.
<r><I>>Bertrand<e></e></I> − <COLOR color=\"#808080\">><B>newLISP<e></e></B> v.10.7.6 64-bit <B>>on Linux<e></e></B> (<I>>Linux Mint 20.1<e></e></I>)<e></e></COLOR></r>