Skip to content

Commit 792e1fa

Browse files
authored
Point out sub EXPORT must be before unit
https://irclog.perlgeek.de/perl6/2018-05-23#i_16195729
1 parent 9e948d0 commit 792e1fa

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

doc/Language/modules.pod6

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -410,6 +410,18 @@ Then use the tag you like and pick the symbol by its name.
410410
# OUTPUT: «(&uri-escape &uri-unescape &uri_escape &uri_unescape)␤»
411411
my &escape-uri = URI::Escape::EXPORT::DEFAULT::<&uri_escape>;
412412
413+
Be careful I<not> to put C<sub EXPORT> after L«C<unit> declarator|/syntax/unit».
414+
If you do so, it'll become just a sub inside your package, rather than the special
415+
export sub:
416+
417+
unit module Bar;
418+
sub EXPORT { %(Foo => &say) } # WRONG!!! Sub is scoped wrong
419+
420+
# ---------
421+
422+
sub EXPORT { %(Foo => &say) } # RIGHT!!! Sub is outside the module
423+
unit module Bar;
424+
413425
=head2 Finding Modules
414426
415427
It is up to the module installer to know where C<compunit> expects modules to

0 commit comments

Comments
 (0)