The scope of local variables -- where are they?

I’m wondering – where /is/ the scope of local variables? Is there any
programmatic way to manipulate a local variable [by this, I rather
awkwardly mean – for example, is there a hash on some object of local
variables? Or something similar?] They seem special to me.

Cheers,
Arlen

I wanna know how to do it so. Some method that receive a simple, just
like
const_(get|set).

I know I can user defined? to test if they are defined, but is there any
way
to get them throught metaprogramming?

On 9/8/07, Bernardo Monteiro R. [email protected] wrote:

I know I can user defined? to test if they are defined, but is there any way
to get them throught metaprogramming?

No (except for eval). What do you want to acheive? Whatever it is,
there is probably another way, barring wanting to mess with local
variables for the sake of messing with local variables.

On 08.09.2007 15:15, Arlen Christian Mart C. wrote:

I’m wondering – where /is/ the scope of local variables? Is there any
programmatic way to manipulate a local variable [by this, I rather
awkwardly mean – for example, is there a hash on some object of local
variables? Or something similar?] They seem special to me.

There is a fairly easy way to manipulate them:

foo = 10

:slight_smile:

If your set of variables you need to manipulate is not fixed you better
use a Hash directly. There are some ways to manipulate “unknown” local
variables, but they typically involve using “eval”. You’ll find plenty
of discussions of this topic in the archives.

Kind regards

robert

On 09/09/2007, Logan C. [email protected] wrote:

One use I could see for reflection on local variables is debugger
support. You’ve run to a breakpoint; what is the full program state?

On 9/8/07, Michael R. [email protected] wrote:

One use I could see for reflection on local variables is debugger
support. You’ve run to a breakpoint; what is the full program state?

That’s a pretty good example :slight_smile: (we do have local_variables, but’s
that is jsut an array of strings)