Skip to content

Commit 694d8b9

Browse files
committed
explain differences in conditionals/while
1 parent ad48c53 commit 694d8b9

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

lib/Language/5to6.pod

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -595,7 +595,15 @@ I<Deleting an element in a hash>
595595
596596
=head4 C<if> C<elsif> C<else> C<unless>
597597
598-
Unchanged; parens around the conditions are now optional.
598+
Mostly unchanged; parens around the conditions are now optional, but if
599+
used, must not immediately follow the keyword, or it will be taken as a function
600+
call instead. Binding the conditional expression to a value is also a little different:
601+
602+
if (my $x = dostuff()) {...} # Perl 5
603+
if dostuff() -> $x {...} # Perl 6
604+
605+
(You can still use the C<my> form in Perl 6, but it will scoped to the
606+
outer block, not the inner.)
599607
600608
=head4 C<given> C<when>
601609
@@ -607,7 +615,15 @@ See also the warnings on the smart-match op above.
607615
608616
=head4 C<while> C<until>
609617
610-
Unchanged; parens around the conditions are now optional.
618+
Mostly unchanged; parens around the conditions are now optional, but if
619+
used, must not immediately follow the keyword, or it will be taken as a function
620+
call instead. Binding the conditional expression to a value is also a little different:
621+
622+
while (my $x = dostuff()) {...} # Perl 5
623+
while dostuff() -> $x {...} # Perl 6
624+
625+
(You can still use the C<my> form in Perl 6, but it will scoped to the
626+
outer block, not the inner.)
611627
612628
Note that reading line-by-line from a filehandle has changed.
613629

0 commit comments

Comments
 (0)