Skip to content

Commit 766353e

Browse files
committed
Reflow and eliminate index, refs #2304
1 parent 10ff0d6 commit 766353e

File tree

1 file changed

+38
-36
lines changed

1 file changed

+38
-36
lines changed

doc/Language/5to6-nutshell.pod6

Lines changed: 38 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -5,36 +5,36 @@
55
=SUBTITLE How do I do what I used to do? (Perl 6 in a nutshell)
66
77
This page attempts to provide a fast-path to the changes in syntax and
8-
semantics from Perl 5 to Perl 6. Whatever worked in Perl 5 and must be written
9-
differently in Perl 6, should be listed here (whereas many I<new> Perl 6
10-
features and idioms are not).
8+
semantics from Perl 5 to Perl 6. Whatever worked in Perl 5 and must be
9+
written differently in Perl 6, should be listed here (whereas many
10+
I<new> Perl 6 features and idioms are not).
1111
12-
Hence this should not be mistaken for a beginner tutorial or a promotional
13-
overview of Perl 6; it is intended as a technical reference for Perl 6
14-
learners with a strong Perl 5 background and for anyone porting Perl 5 code
15-
to Perl 6 (though note that L<#Automated translation> might be more
16-
convenient).
12+
Hence this should not be mistaken for a beginner tutorial or a
13+
promotional overview of Perl 6; it is intended as a technical reference
14+
for Perl 6 learners with a strong Perl 5 background and for anyone
15+
porting Perl 5 code to Perl 6 (though note that L<#Automated
16+
translation> might be more convenient).
1717
1818
A note on semantics; when we say "now" in this document, we mostly just
1919
mean "now that you are trying out Perl 6." We don't mean to imply that
2020
Perl 5 is now suddenly obsolete. Quite the contrary, most of us love
2121
Perl 5, and we expect Perl 5 to continue in use for a good many years.
22-
Indeed, one of our more important goals has been to make interaction between
23-
Perl 5 and Perl 6 run smoothly. However, we do also like the design
24-
decisions in Perl 6, which are certainly newer and arguably better
25-
integrated than many of the historical design decisions in Perl 5.
26-
So many of us do hope that over the next decade or two, Perl 6 will
22+
Indeed, one of our more important goals has been to make interaction
23+
between Perl 5 and Perl 6 run smoothly. However, we do also like the
24+
design decisions in Perl 6, which are certainly newer and arguably
25+
better integrated than many of the historical design decisions in Perl
26+
5. So many of us do hope that over the next decade or two, Perl 6 will
2727
become the more dominant language. If you want to take "now" in that
2828
future sense, that's okay too. But we're not at all interested in the
2929
either/or thinking that leads to fights.
3030
3131
=head1 CPAN
3232
33-
See L<https://modules.perl6.org/> .
33+
See L<https://modules.perl6.org/>.
3434
35-
If the module that you were using has not been converted to Perl 6, and no
36-
alternative is listed in this document, then its use under Perl 6 may not
37-
have been addressed yet.
35+
If the module that you were using has not been converted to Perl 6, and
36+
no alternative is listed in this document, then its use under Perl 6 may
37+
not have been addressed yet.
3838
3939
The L<Inline::Perl5|https://github.com/niner/Inline-Perl5/> project makes
4040
it possible to C<use> Perl 5 modules directly from Perl 6 code by using
@@ -1477,10 +1477,9 @@ The L«C<FALLBACK> method|/language/typesystem#index-entry-FALLBACK_(method)»
14771477
provides similar functionality.
14781478
14791479
=head2 Importing specific functions from a module
1480-
X<|import>
14811480
1482-
In Perl 5 it is possible to selectively import functions from a given module
1483-
like so:
1481+
In Perl 5 it is possible to selectively import functions from a given
1482+
module like so:
14841483
14851484
=for code :lang<perl5>
14861485
use ModuleName qw{foo bar baz};
@@ -1498,23 +1497,24 @@ sub bar($b) is export { say "bar $b" }
14981497
sub baz($z) { say "baz $z" }
14991498
=end code
15001499
1501-
To use this module, simply C<use Bar> and the functions C<foo> and C<bar>
1502-
will be available
1500+
To use this module, simply C<use Bar> and the functions C<foo> and
1501+
C<bar> will be available
15031502
15041503
=for code :skip-test
15051504
use Bar;
15061505
foo(1); #=> "foo 1"
15071506
bar(2); #=> "bar 2"
15081507
1509-
If one tries to use C<baz> an "Undeclared routine" error is raised at compile time.
1508+
If one tries to use C<baz> an "Undeclared routine" error is raised at
1509+
compile time.
15101510
1511-
So, how does one recreate the Perl 5 behaviour of being able to selectively
1512-
import functions? For this one needs to define an C<EXPORT> sub inside the
1513-
module which specifies the functions to be exported and remove the C<module Bar>
1514-
statement.
1511+
So, how does one recreate the Perl 5 behaviour of being able to
1512+
selectively import functions? For this one needs to define an C<EXPORT>
1513+
sub inside the module which specifies the functions to be exported and
1514+
remove the C<module Bar> statement.
15151515
1516-
The module C<Bar> now is merely a file called C<Bar.pm> with the following
1517-
contents:
1516+
The module C<Bar> now is merely a file called C<Bar.pm> with the
1517+
following contents:
15181518
15191519
=begin code :preamble<no strict;>
15201520
use v6.c;
@@ -1538,14 +1538,16 @@ sub bar($a) { say "bar, $a" }
15381538
sub baz($z) { say "baz, $z" }
15391539
=end code
15401540
1541-
Note that the subs are no longer explicitly exported via the C<is export>
1542-
role. We are defining an C<EXPORT> sub which specifies the subs in the
1543-
module we want to be available for export and then we are populating a hash
1544-
containing the subs which will actually be exported. The C<@import-list> is
1545-
set by the C<use> statement in the calling code thus allowing us to
1546-
selectively import the subs made available by the module.
1541+
Note that the subs are no longer explicitly exported via the C<is
1542+
export> role. We are defining an C<EXPORT> sub which specifies the subs
1543+
in the module we want to be available for export and then we are
1544+
populating a hash containing the subs which will actually be exported.
1545+
The C<@import-list> is set by the C<use> statement in the calling code
1546+
thus allowing us to selectively import the subs made available by the
1547+
module.
15471548
1548-
So, to import only the C<foo> routine, we do the following in the calling code:
1549+
So, to import only the C<foo> routine, we do the following in the
1550+
calling code:
15491551
15501552
=for code :skip-test
15511553
use Bar <foo>;

0 commit comments

Comments
 (0)