@@ -255,16 +255,22 @@ to C<use>, the C<EXPORT> sub handles positional parameters. If you
255
255
pass positional parameters to C < use > they will be passed to
256
256
C < EXPORT > . If a positional is passed the module no longer exports
257
257
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.
259
259
260
260
= begin code
261
261
# lib/MyModule
262
262
263
263
class MyModule::Class {}
264
264
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; };
266
270
{
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:<~>
268
274
}
269
275
}
270
276
@@ -283,23 +289,6 @@ passing C<:DEFAULT> to C<use> along with your positional parameters.
283
289
shy(); #FAIL - won't be imported
284
290
= end code
285
291
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
-
303
292
= head1 Distributing Modules
304
293
305
294
If you've written a Perl 6 module and would like to share it with the
0 commit comments