Skip to content

Commit 24d7ce0

Browse files
committed
Revision, grammar and reflow
1 parent 461382f commit 24d7ce0

File tree

1 file changed

+31
-27
lines changed

1 file changed

+31
-27
lines changed

doc/Language/5to6-nutshell.pod6

Lines changed: 31 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1119,7 +1119,8 @@ a better choice for grammar reuse.
11191119
11201120
=head2 Named captures
11211121
1122-
These work in a slightly different way; also they only work in the latest versions of Perl 5.
1122+
These work in a slightly different way; also they only work in the latest
1123+
versions of Perl 5.
11231124
11241125
=for code :lang<perl5>
11251126
use v5.22;
@@ -1154,15 +1155,14 @@ differences!
11541155
11551156
=head2 UNITCHECK becomes CHECK
11561157
1157-
There is currently B<no> direct equivalent of C<CHECK> blocks in Perl 6.
1158-
The C<CHECK> phaser in Perl 6 has the same semantics as the C<UNITCHECK>
1159-
block in Perl 5: it gets run whenever the compilation unit in which it
1160-
occurs, has finished parsing. This is considered a much saner semantic
1161-
than the current semantics of C<CHECK> blocks in Perl 5. But for
1162-
compatibility reasons, it was impossible to change the semantics of C<CHECK>
1163-
blocks in Perl 5, so a C<UNITCHECK> block was introduced in 5.10. So it
1164-
was decided that the Perl 6 C<CHECK> phaser would follow the saner Perl 5
1165-
C<UNITCHECK> semantics.
1158+
There is currently B<no> direct equivalent of C<CHECK> blocks in Perl 6. The
1159+
C<CHECK> phaser in Perl 6 has the same semantics as the C<UNITCHECK> block in
1160+
Perl 5: it gets run whenever the compilation unit in which it occurs has
1161+
finished parsing. This is considered a much saner semantic than the current
1162+
semantics of C<CHECK> blocks in Perl 5. But for compatibility reasons, it was
1163+
impossible to change the semantics of C<CHECK> blocks in Perl 5, so a
1164+
C<UNITCHECK> block was introduced in 5.10. Consequently, it was decided that
1165+
the Perl 6 C<CHECK> phaser would follow the saner Perl 5 C<UNITCHECK> semantics.
11661166
11671167
=head2 No block necessary
11681168
@@ -1178,11 +1178,11 @@ BEGIN my $foo = 42; # Perl 6
11781178
11791179
=head2 Changed semantics with regards to precompilation
11801180
1181-
If you put C<BEGIN> and C<CHECK> phasers in a module that is being
1182-
precompiled, then these phasers will B<only> be executed during precompilation
1183-
and B<not> when a precompiled module is being loaded. So when porting module
1184-
code from Perl 5, you may need to change C<BEGIN> and C<CHECK> blocks to
1185-
C<INIT> blocks to ensure that they're run when loading that module.
1181+
If you put C<BEGIN> and C<CHECK> phasers in a module that is being precompiled,
1182+
then these phasers will B<only> be executed during precompilation and B<not>
1183+
when a precompiled module is being loaded. So when porting module code from
1184+
Perl 5, you may need to change C<BEGIN> and C<CHECK> blocks to C<INIT> blocks to
1185+
ensure that they're run when loading that module.
11861186
11871187
=head1 Pragmas
11881188
@@ -1195,7 +1195,7 @@ Strict mode is now on by default.
11951195
Warnings are now on by default.
11961196
11971197
C<no warnings> is currently L<NYI|/language/glossary#NYI>,
1198-
but putting things in a quietly {} block will silence.
1198+
but putting things in a C<quietly> {} block will silence.
11991199
12001200
=head3 C<autodie>
12011201
@@ -1281,10 +1281,11 @@ time being, only utf8 for its scripts.
12811281
=head3 C<integer>
12821282
12831283
Perl pragma to use integer arithmetic instead of floating point. There is
1284-
no such equivalent in Perl 6. If you use native integers in your calculations,
1284+
no such thing in Perl 6. If you use native integers in your calculations,
12851285
then this will be the closest thing.
12861286
12871287
=for code
1288+
#Perl 6
12881289
my int $foo = 42;
12891290
my int $bar = 666;
12901291
say $foo * $bar; # uses native integer multiplication
@@ -1382,7 +1383,8 @@ Removed.
13821383
13831384
=item C<-P> C<-u> C<-U> C<-W> C<-X>
13841385
1385-
Removed. See L<S19#Removed Syntactic Features|https://design.perl6.org/S19.html#Removed_Syntactic_Features>.
1386+
Removed. See
1387+
L<Removed Syntactic Features|https://design.perl6.org/S19.html#Removed_Syntactic_Features>.
13861388
13871389
=item C<-w>
13881390
@@ -1429,16 +1431,18 @@ the C<lines> method on the result of C<slurp> instead:
14291431
14301432
my @lines = "test-file".IO.slurp.lines; # also auto-chomps
14311433
1432-
Also, be aware that $! is not really relevant for file IO operation failures in
1433-
Perl 6. An IO operation that fails will return a failure instead of throwing an
1434-
exception. If you want to return the failure message, it is in the failure
1435-
itself, not in $!. To do similar IO error checking and reporting as in Perl 5:
1434+
Also, be aware that C<$!> is not really relevant for file IO operation failures
1435+
in Perl 6. An IO operation that fails will return a C<Failure> instead of
1436+
throwing an exception. If you want to return the failure message, it is in the
1437+
failure itself, not in C<$!>. To do similar IO error checking and reporting as
1438+
in Perl 5:
14361439
14371440
my $fh = open('./bad/path/to/file', :w) or die $fh;
14381441
1439-
Note: $fh instead of $!. Or, you can set $_ to the failure and die with $_:
1442+
I<Note>: C<$fh> instead of C<$!>. Or, you can set C<$_> to the failure and die
1443+
with $_:
14401444
1441-
my $fh = open('./bad/path/to/file', :w) orelse .die;
1445+
my $fh = open('./bad/path/to/file', :w) orelse .die; # Perl 6
14421446
14431447
Any operation that tries to use the failure will cause the program to fault and
14441448
terminate. Even just a call to the C<.self> method is sufficient.
@@ -1454,7 +1458,7 @@ my $arg = 'Hello';
14541458
my $captured = `echo \Q$arg\E`;
14551459
my $captured = qx(echo \Q$arg\E);
14561460
1457-
Or using String::ShellQuote (because C<\Q…\E> is not completely right):
1461+
Or using C<String::ShellQuote> (because C<\Q…\E> is not completely right):
14581462
14591463
=for code :lang<perl5>
14601464
my $arg = shell_quote 'Hello';
@@ -1477,7 +1481,7 @@ But beware that in this case there is B<no protection at all>! C<run> does
14771481
not use the shell, so there is no need to escape the arguments (arguments
14781482
are passed directly). If you are using C<shell> or C<qqx>, then everything
14791483
ends up being one long string which is then passed to the shell. Unless you
1480-
validate your arguments very carefully, there is a high chance to introduce
1484+
validate your arguments very carefully, there is a high chance of introducing
14811485
shell injection vulnerabilities with such code.
14821486
14831487
=head1 Environment variables
@@ -1541,7 +1545,7 @@ In Perl 6 becomes a simple
15411545
15421546
Gone.
15431547
1544-
The Perl 6 design allows for automatic transparent saving-and-loading of
1548+
The Perl 6 design allows for automatic and transparent saving-and-loading of
15451549
compiled bytecode.
15461550
15471551
Rakudo supports this only for modules so far.

0 commit comments

Comments
 (0)