closure & local_variables

  • Thread starter Marcin MielżyÅ„ski
  • Start date
M

Marcin Mielżyński

Hello,

given:

l=lambda{p local_variables;p a}
a=:whatever
l[]

I know that 'a' variable shoud not be visible for closure, but why
local_variables reports that it exists ? Is this behaviour intended ?

lopex
 
L

Logan Capaldo

Hello,

given:

l=3Dlambda{p local_variables;p a}
a=3D:whatever
l[]

I know that 'a' variable shoud not be visible for closure, but why =20
local_variables reports that it exists ? Is this behaviour intended ?

lopex

l is closing over main, main has a local_variables method, that is =20
what is being called not the proc's local_variables.
 
E

E. Saynatkari

Marcin said:
Hello,

given:

l=lambda{p local_variables;p a}
a=:whatever
l[]

I know that 'a' variable shoud not be visible for closure, but why
local_variables reports that it exists ? Is this behaviour intended ?

Well, #local_variables is a method call so it resolves
at call time (at which point a is included). You could
also #eval 'a' at that point :)


E
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,430
Messages
2,571,676
Members
48,796
Latest member
Greg L.

Latest Threads

Top