Skip to content

Commit

Permalink
Merge pull request #347 from gfldex/master
Browse files Browse the repository at this point in the history
merge redundant examples and add type capture
  • Loading branch information
gfldex committed Jan 14, 2016
2 parents b333245 + ed2d1ce commit ebdd00a
Showing 1 changed file with 9 additions and 20 deletions.
29 changes: 9 additions & 20 deletions doc/Language/modules.pod
Original file line number Diff line number Diff line change
Expand Up @@ -255,16 +255,22 @@ to C<use>, the C<EXPORT> sub handles positional parameters. If you
pass positional parameters to C<use> they will be passed to
C<EXPORT>. If a positional is passed the module no longer exports
default symbols. You may still import them explicitly by
passing C<:DEFAULT> to C<use> along with your positional parameters.
passing C<:DEFAULT> to C<use> along with your positional parameters. Type captures are supported and operators can be exported via their long name.
=begin code
# lib/MyModule
class MyModule::Class {}
sub EXPORT($short_name?) {
sub EXPORT($short_name?, ::T) {
role R[::TT] { }
class C { }
multi sub infix:<~>(C \l, T \r){ note "supressed concat with: ", T.WHAT; };
multi sub infix:<~>(T \l, C \r){ note "supressed concat with: ", T.WHAT; };
{
do $short_name => MyModule::Class if $short_name
do $short_name => MyModule::Class if $short_name,
'MixedC' => C but R.^parameterize(T), # workaround for RT#127256
'infix:<~>' => &infix:<~>
}
}
Expand All @@ -283,23 +289,6 @@ passing C<:DEFAULT> to C<use> along with your positional parameters.
shy(); #FAIL - won't be imported
=end code
C<EXPORT> can take arguments, given it was provided with a signature. Type
captures are supported.
# lib/MyModule.pm
sub EXPORT(Int $i = 42) {
{
'foo' => sub () { $i }
}
}
# main.pl
use MyModule 666;
foo(); # 666
=head1 Distributing Modules
If you've written a Perl 6 module and would like to share it with the
Expand Down

0 comments on commit ebdd00a

Please sign in to comment.