From: Zev Blut Date: 2005-06-09T22:13:38+09:00 Subject: Re: binding, ObjectSpace._id2ref [WAS] Re: [ANN] parseargs-0.0.0 Hello, Sorry for the late reply. On Thu, 02 Jun 2005 21:33:29 +0900, Glenn Parker wrote: > Zev Blut wrote: >> If you cannot access a in your binding, why would eval add a to the >> local_variables? Can anyone explain this? I would like to know. > > It is a curious side effect of the way Ruby is interpreted. Perhaps it > is a performance optimization? It doesn't really have to be this way, > but it won't affect you (much) in practical terms. > > Variables that are "visible" when a method is compiled are added to a > table somewhere in the AST, and only those variables can be accessed > directly in that method. Clearly, this table is not the same one that > "eval" consults so we have, to put it diplomatically, a little > disconnect. Eval can find the variable when asked, but the interpreter > simply refuses to go looking for it in the first place. Thanks a lot for the explanation! It certainly makes sense now. Cheers, Zev