Skip to content

Commit 20a3a7e

Browse files
committed
Reflow and rephrasing
1 parent 0304aaf commit 20a3a7e

File tree

1 file changed

+24
-23
lines changed

1 file changed

+24
-23
lines changed

doc/Language/5to6-nutshell.pod6

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1541,10 +1541,10 @@ module like so:
15411541
=for code :lang<perl5>
15421542
use ModuleName qw{foo bar baz};
15431543
1544-
In Perl 6 one specifies the functions which are to be exported by using the
1545-
C<is export> role on the relevant subs and I<all> subs with this role are
1546-
then exported. Hence, the following module C<Bar> exports the subs C<foo>
1547-
and C<bar> but not C<baz>:
1544+
In Perl 6 one specifies the functions which are to be exported by using
1545+
the C<is export> role on the relevant subs; I<all> subs with this role
1546+
are then exported. Hence, the following module C<Bar> exports the subs
1547+
C<foo> and C<bar> but not C<baz>:
15481548
15491549
=begin code :solo
15501550
unit module Bar;
@@ -1566,11 +1566,11 @@ If one tries to use C<baz> an "Undeclared routine" error is raised at
15661566
compile time.
15671567
15681568
So, how does one recreate the Perl 5 behaviour of being able to
1569-
selectively import functions? For this one needs to define an C<EXPORT>
1570-
sub inside the module which specifies the functions to be exported and
1571-
remove the C<module Bar> statement.
1569+
selectively import functions? By defining an C<EXPORT> sub inside the
1570+
module which specifies the functions to be exported and removing the
1571+
C<module Bar> statement.
15721572
1573-
The module C<Bar> now is merely a file called C<Bar.pm6> with the
1573+
The former module C<Bar> now is merely a file called C<Bar.pm6> with the
15741574
following contents:
15751575
15761576
=begin code :preamble<no strict;>
@@ -1594,8 +1594,8 @@ sub baz($z) { say "baz, $z" }
15941594
=end code
15951595
15961596
Note that the subs are no longer explicitly exported via the C<is
1597-
export> role. We are defining an C<EXPORT> sub which specifies the subs
1598-
in the module we want to be available for export and then we are
1597+
export> role, but by an C<EXPORT> sub which specifies the subs
1598+
in the module we want to make available for export and then we are
15991599
populating a hash containing the subs which will actually be exported.
16001600
The C<@import-list> is set by the C<use> statement in the calling code
16011601
thus allowing us to selectively import the subs made available by the
@@ -1608,7 +1608,7 @@ calling code:
16081608
use Bar <foo>;
16091609
foo(1); #=> "foo 1"
16101610
1611-
Here we see that even though C<bar> is able to be exported, if we don't
1611+
Here we see that even though C<bar> is exportable, if we don't
16121612
explicitly import it, it's not available for use. Hence this causes an
16131613
"Undeclared routine" error at compile time:
16141614
@@ -1617,33 +1617,34 @@ use Bar <foo>;
16171617
foo(1);
16181618
bar(5); #!> "Undeclared routine: bar used at line 3"
16191619
1620-
however, this will work
1620+
However, this will work
16211621
16221622
=for code :skip-test
16231623
use Bar <foo bar>;
16241624
foo(1); #=> "foo 1"
16251625
bar(5); #=> "bar 5"
16261626
1627-
Note also that C<baz> remains unimportable even if specified in the C<use>
1628-
statement:
1627+
Note also that C<baz> remains unimportable even if specified in the
1628+
C<use> statement:
16291629
16301630
=for code :skip-test
16311631
use Bar <foo bar baz>;
16321632
baz(3); #!> "Undeclared routine: baz used at line 2"
16331633
1634-
In order to get this to work, one obviously has to jump through many hoops.
1635-
In the standard use-case where one specifies the functions to be exported
1636-
via the C<is export> role, Perl 6 automatically creates the C<EXPORT> sub in
1637-
the correct manner for you, so one should consider very carefully whether or
1638-
not writing one's own C<EXPORT> routine is worthwhile.
1634+
In order to get this to work, one obviously has to jump through many
1635+
hoops. In the standard use-case where one specifies the functions to be
1636+
exported via the C<is export> role, Perl 6 automatically creates the
1637+
C<EXPORT> sub in the correct manner for you, so one should consider very
1638+
carefully whether or not writing one's own C<EXPORT> routine is
1639+
worthwhile.
16391640
16401641
=head2 Importing groups of specific functions from a module
16411642
16421643
If you would like to export groups of functions from a module, you just
1643-
need to assign names to the groups, and the rest will work automagically.
1644-
When you specify C<is export> in a sub declaration, you are in fact adding
1645-
this subroutine to the C<:DEFAULT> export group. But you can add a subroutine
1646-
to another group, or to multiple groups:
1644+
need to assign names to the groups, and the rest will work
1645+
automagically. When you specify C<is export> in a sub declaration, you
1646+
are in fact adding this subroutine to the C<:DEFAULT> export group. But
1647+
you can add a subroutine to another group, or to multiple groups:
16471648
16481649
=for code :solo
16491650
unit module Bar;

0 commit comments

Comments
 (0)