Garrett Goebel <[EMAIL PROTECTED]> wrote
> From: Dave Mitchell [mailto:[EMAIL PROTECTED]]

> > sub Foo::import {
> >     my %m = caller(1).{MY}; # or whatever
> >     %m{'$x'} = 1;
> > }
...
> > sub f {
> >     my $x = 9;
> >     use Foo; # does $x become 1, or $x redefined, or runtime 
> >              # error, or ... ?
> 
> do you mean Foo::import()? 'use' is handled like:
> 
> BEGIN {
>   require Foo;
>   Foo::import(@_);
> }
> 
> So 'use Foo' would modify the caller, which being processed at compile time
> would be 'main'. So this would create a my $x in the scope of the main_cv.
> Which would then be removed by the later 'use Bar'.


I meant 'use Foo', in the sense of wanting (at compile time) to modify the
lexical state of the place where 'use' appears (ie f()), since this
appears to be the main reason why people wanted the %MY:: feature in the
first place. Hence the "or whatever" comment in the vague, hand-waving
"my %m = caller(1).{MY}" bit.  Clearly caller() isn't what we want here, but
I'm not quite sure what would be the correct incantation.

Reply via email to