Browse files

a little more word-smithing

attempt at clarity--please change or comment
  • Loading branch information...
1 parent 11c89a0 commit 159f1ef02e4d73a1d6072518d76b2f5498b6e711 @tbrowder tbrowder committed on GitHub Feb 17, 2017
Showing with 16 additions and 3 deletions.
  1. +16 −3 doc/Language/control.pod6
@@ -306,7 +306,7 @@ There are also C<with> and C<without> statement modifiers:
=head1 X<when|control flow>
The C<when> block is similar to an C<if> block and either or both can be used
-in an outer block, they also both have a statement modifier form.
+in an outer block, they also both have a "statement modifier form."
But there is a difference in how following code in the same, outer
block is handled: When the C<when> block is executed, control is passed to
the enclosing block and following statements are ignored; but when the C<if>
@@ -332,9 +332,22 @@ Should the C<if> and C<when> blocks above appear at file scope, following
statements would be executed in each case.
There is one other feature a C<when> has that C<if> doesn't: the C<when>'s boolean
-test defaults to C<$_ ~~> while the C<if>'s does not.
+context test defaults to C<$_ ~~> while the C<if>'s does not. That has an effect on
+how one uses the X in the C<when> block without a value for <$_> (it's 'Any' in
+that case and Any smart matches on True: Any ~~ True => True). Consider the following:
-C<when> also has a statement modifier form which does not effect execution
+=begin code :skip-test
+ my $a = 1;
+ my $b = True;
+ when $a { say 'a' }; # no output
+ when so $a { say 'a' } # a (in "so $a" 'so' coerces $a to Boolean context True
+ # which matches with Any)
+ when $b { say 'b' }; # b (b is True as defined so matches with Any)
+=end code
+Finally, C<when>'s statement modifier form does not effect execution
of following statements either inside or outside of another block:
=begin code :skip-test

0 comments on commit 159f1ef

Please sign in to comment.