This and other RFCs are available on the web at http://tmtowtdi.perl.org/rfc/ =head1 TITLE Module Scope Control =head1 VERSION Maintainer: Bryan C. Warnock <[EMAIL PROTECTED]> Date: 5 Aug 2000 Version: 1 Mailing List: [EMAIL PROTECTED] Number: 40 =head1 ABSTRACT Modules should be able to, internally, control how they (and their members) are scoped. =head1 DESCRIPTION Hooks should allowed so that module writers can control global and lexical scoping of its own subs and variables. package MyModule; @globals = qw/$foo $bar %hash @array/; @lexicals = qw/$ork $gork @hork $./; BEGIN{$. = 834;} #!/usr/local/bin/perl use MyModule; # same as use MyModule; local $ork; local $.=834; use OtherPackage; print $MyModule::foo; # Okay, it exists foo() if ($MyModule::$ork); # Okay, it's scoped here. OtherPackage::bar(); print $.; # Prints 834. package OtherPackage; sub bar { print $MyModule::$bar; # Okay, global. print $MyModule::$hork[0]; # Nope, not seen down here. print $.; Prints whatever it was before 834. 0? } (This is not to suggest that this be the syntax.) =head1 MOTIVATORS Impatience, and a little laziness. =head1 IMPLEMENTATION I'm not too terribly sure I even got the terminology correct. Scoping makes my head hurt. :-( I'll concede right now, the above is a mess, and I'd like to find a more elegant way of handling this. The point is to allow a module to define (or override) variables only in the file where C<use $Module;> was invoked. I thought there was something in Perl 5 that made this easier from a core perspective, but it seemed to be overly complex for my puny little brain. This should allow modules to behave like pragmas, in some respects. =head2 SUMMARY OF IMPLEMENTATION I've no real concrete ideas on this, sorry. =head2 IMPACT =over 4 =item * Impact on Perl 5. Mutual compatibility between Perl 5 and Perl 6, with the exception of this feature and the sematics it would add. (Obviously, other changes to the language notwithstanding.) =back =head1 REFERENCES RFC 2 (which could then be written as a module), and a forthcoming RFC on the Shell pragma. (Which could also then be written as a module.)