let and letn

Q&A's, tips, howto's
Locked
newBert
Posts: 156
Joined: Fri Oct 28, 2005 5:33 pm
Location: France

let and letn

Post by newBert »

I don't understand why letn isn't required here, or why let doesn't cause an error:

Code: Select all

(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))
BertrandnewLISP v.10.7.6 64-bit on Linux (Linux Mint 20.1)

ralph.ronnquist
Posts: 228
Joined: Mon Jun 02, 2014 1:40 am
Location: Melbourne, Australia

Re: let and letn

Post by ralph.ronnquist »

Hmm. I get

Code: Select all

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

cameyo
Posts: 183
Joined: Sun Mar 27, 2011 3:07 pm
Location: Italy
Contact:

Re: let and letn

Post by cameyo »

I get:

Code: Select all

(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
Posts: 607
Joined: Fri Apr 08, 2005 7:13 pm
Location: Front Royal, Virginia

Re: let and letn

Post by rickyboy »

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
Posts: 156
Joined: Fri Oct 28, 2005 5:33 pm
Location: France

Re: let and letn [resolved]

Post by newBert »

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.
BertrandnewLISP v.10.7.6 64-bit on Linux (Linux Mint 20.1)

Locked