Dave Mitchell asked:
> If there is to be a %MY, how does its semantics pan out?
That's %MY::. The colons are part of the name.
> for example, what (if anything) do the following do:
>
> sub Foo::import {
> my %m = caller(1).{MY}; # or whatever
> %m{'$x'} = 1;
> }
That would be:
sub Foo::import {
my $m = caller(1).{MY};
$m{'$x'} = \1;
}
Symbol table entries store references (to the actualy storage), not values.
My above example would make the lexical $x variable in the caller's scope
equivalent to:
my $x : const = 1;
> sub Bar::import {
> my %m = caller(1).{MY}; # or whatever
> delete %m{'$x'};
> }
That would be:
sub Bar::import {
my $m = caller(1).{MY};
delete $m{'$x'};
}
which would cause the next attempted access to the lexical $x in the
caller's scope to throw an exception.
> sub f {
> my $x = 9;
> use Foo; # does $x become 1, or $x redefined, or runtime error, or...?
$x becomes constant, with value 1.
> {
> # is this the same as 'my $x = 1' at this point,
Yes.
> # or is the outer $x modified?
No.
> use Foo;
> ...
> }
Because %MY:: is lexical to each scope.
> use Bar; # is $x now still in scope?
No.
> print $x; #compile error? or runtime error? or prints 9 (or 1...) ????
Run-time exception.
> Bar::import(); # any difference calling it at run time?
No.
> IE what effects to do the standard hash ops of adding, modifying,
> deleting, testing for existence, testing for undefness, etc etc map onto
> when applied to some sub's %MY, at either compile or run time.
No difference between compile- and run-times.
Effects:
What Effect
add entry to %MY:: Creates new lexical in scope
modify entry in %MY:: Changes implementation of lexical
delete entry in %MY: Prematurely removes lexical from scope
existence test entry in %MY:: Does lexical exist in scope?
definition test entry in %MY:: Is lexical implemented in scope?
Damian