Skip to content

Commit ebdd00a

Browse files
committed
Merge pull request #347 from gfldex/master
merge redundant examples and add type capture
2 parents b333245 + ed2d1ce commit ebdd00a

File tree

1 file changed

+9
-20
lines changed

1 file changed

+9
-20
lines changed

doc/Language/modules.pod

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -255,16 +255,22 @@ to C<use>, the C<EXPORT> sub handles positional parameters. If you
255255
pass positional parameters to C<use> they will be passed to
256256
C<EXPORT>. If a positional is passed the module no longer exports
257257
default symbols. You may still import them explicitly by
258-
passing C<:DEFAULT> to C<use> along with your positional parameters.
258+
passing C<:DEFAULT> to C<use> along with your positional parameters. Type captures are supported and operators can be exported via their long name.
259259
260260
=begin code
261261
# lib/MyModule
262262
263263
class MyModule::Class {}
264264
265-
sub EXPORT($short_name?) {
265+
sub EXPORT($short_name?, ::T) {
266+
role R[::TT] { }
267+
class C { }
268+
multi sub infix:<~>(C \l, T \r){ note "supressed concat with: ", T.WHAT; };
269+
multi sub infix:<~>(T \l, C \r){ note "supressed concat with: ", T.WHAT; };
266270
{
267-
do $short_name => MyModule::Class if $short_name
271+
do $short_name => MyModule::Class if $short_name,
272+
'MixedC' => C but R.^parameterize(T), # workaround for RT#127256
273+
'infix:<~>' => &infix:<~>
268274
}
269275
}
270276
@@ -283,23 +289,6 @@ passing C<:DEFAULT> to C<use> along with your positional parameters.
283289
shy(); #FAIL - won't be imported
284290
=end code
285291
286-
C<EXPORT> can take arguments, given it was provided with a signature. Type
287-
captures are supported.
288-
289-
# lib/MyModule.pm
290-
291-
sub EXPORT(Int $i = 42) {
292-
{
293-
'foo' => sub () { $i }
294-
}
295-
}
296-
297-
# main.pl
298-
299-
use MyModule 666;
300-
301-
foo(); # 666
302-
303292
=head1 Distributing Modules
304293
305294
If you've written a Perl 6 module and would like to share it with the

0 commit comments

Comments
 (0)