From: Fabrizio Morbini

Subject: Scope 2...

Date: 2003-1-29 2:52

Hi, thank you very much for all the response to my previous mail!

Take this example:

(setq a 6)

(flet (
       (prova () (print a))
       )
      (let ((a 4))
	(print a)
	(prova)))

(print a)

The output is:

print: 4
prova: 6
print: 6

This is because the function prova isn't in the lexical environment
created by let...

using defvar instead of setq the output is:

print: 4
prova: 4
print: 6

*Why the let hidden the dinamic scope variable "a" (defvar) but not when
this is created by setq? My response is: because let start a new empty
lexical environment that doesn't contain "a" so let can't hidden a
variable that can't see... is correct?

Take this example:

(let ((a 6))
  (flet (
	 (prova () (print a))
	 )
	(print a)
	(let ((a 4))
	  (print a)
	  (prova)))
  (print a)
  )

the output is:

print: 6
print: 4
prova: 6
print: 6

This seems to reinforce my previous answer...

Thank you very much and best regards!

Fabrizio.