Brent Dax wrote:
> Perl, however, is such a dynamic language you can't do a lot of that
> resolution at compile-time.  What happens when I say:
>         $x="foo";
>         $::{"x"}=\"bar";
>         print $x;

Just so we're clear, $x is a global variable -- there's only
one $x and it never goes out of scope.

This is a little different from the general case of working
with a symbol table containing lexicals defined in inner scopes.

> # From: [EMAIL PROTECTED]
> # You can't store lexical variable definitions in a global symbol
> # table. What happens when you try to access a local variable that
> # doesn't exist because it isn't in scope? Also, many of the scopes
> # that contain variables aren't named. How would you differentiate
> # between the following two "$x" variables?
> #
> #   sub f() { if (...) { my $x; ... } else { my $x; ... } }
> 
> That's not terribly hard--the two ${x}es are in unrelated scopes.

Ok, great. Please answer some questions on this "easy" case
before we move on to the harder cases:

1. What are the "full" names of the two $x variables?

2. What happens if you try to access them when they
don't exist because the scope hasn't been entered?

3. If you are able to modify the definition of $x,
does the change affect the current scope only or the
current scope and all future instances of the current
scope? (Or something else entirely?)

> # If you want to grab a lexical, you *must* be in scope. If you're
> # already in scope there's no reason for "MY::" -- just use the
> # variable's real name.
> 
> But we've promised to support %MY::.

Here's Larry's intention from Apocalypse 2:

| In Perl 5, lexical scopes are unnamed and unnameable. In Perl 6,
| the current lexical scope will have a name that is visible within
| the lexical scope as the pseudo class MY, so that such a scope
| can, if it so chooses, delegate management of its lexical scope
| to some other module at compile time. In normal terms, that means

Note: no promises about run time!

| that when you use a module, you can let it import things
| lexically as well as packagely.

Where has it been determined that %MY:: will even exist, let
alone work the way you want it to? I don't even see where the
current scope will be accessible from Perl -- it might be an
internal implementation feature only.

> # It sounds like you just want a simple way of getting the variables
> # in scope -- are you writing a debugger? I agree with you that it would
> # be very nice to have a low-level debugging API that doesn't treat
> # lexicals differently than globals.
> 
>         our($x)="global";
>         {
>                 my($x)="local";
>           print join ' ', $x, ${"x"};
>         }

That looks suspiciously like an ad hoc debugger to me... ;)

- Ken

Reply via email to