Author: autrijus Date: Thu Feb 23 13:25:31 2006 New Revision: 7812 Modified: doc/trunk/design/syn/S11.pod Log: * S11: Inner modules can now decalare "is export" as well; exports are now collected with the inner ::EXPORT module, with tagsets as inner modules within it; "use" can now re-export the symbols with :EXPORT.
Modified: doc/trunk/design/syn/S11.pod ============================================================================== --- doc/trunk/design/syn/S11.pod (original) +++ doc/trunk/design/syn/S11.pod Thu Feb 23 13:25:31 2006 @@ -77,13 +77,34 @@ Module traits are set using C<is>: Exportation is now done by trait declaration on the exportable item: - # Tagset... + module Foo; # Tagset... sub foo is export(:DEFAULT) {...} # :DEFAULT, :ALL sub bar is export(:DEFAULT :others) {...} # :DEFAULT, :ALL, :others sub baz is export(:MANDATORY) {...} # (always exported) sub bop is export {...} # :ALL sub qux is export(:others) {...} # :ALL, :others +Declarations marked as C<is export> are bound into the C<EXPORT> inner +modules, with their tagsets as inner module names within it. For example, +the C<sub bar> above will bind as C<&Foo::EXPORT::DEFAULT::bar>, +C<&Foo::EXPORT::ALL::bar>, and C<&Foo::EXPORT::others::bar>. + +Inner modules automatically add their export list to modules in its +all outer scope: + + module Foo { + sub foo is export {...} + module Bar { + sub bar is export {...} + module Baz { + sub baz is export {...} + } + } + } + +The C<Foo> module will export C<&foo>, C<&bar> and C<&baz> by default; +calling C<Foo::Bar.import> will import C<&bar> and C<&baz> at runtime. + =head1 Compile-time Importation Importing via C<use> binds into the current lexical scope by default @@ -102,6 +123,12 @@ That's pretty much equivalent to: our @horse ::= @Sense::horse; $*warming ::= $Sense::warming; +It is also possible to re-export the imported symbols: + + use Sense :EXPORT; # import and re-export the defaults + use Sense <common> :EXPORT; # import "common" and re-export it + use Sense <common> :EXPORT<@horse>; # import "common" but exports "@horse" + In the absence of a specific scoping specified by the caller, the module may also specify a different scoping default by use of C<:MY> or C<:OUR> tags as arguments to C<is export>. (Of course, mixing incompatible scoping