Skip to content

Commit

Permalink
emphasize probs with when
Browse files Browse the repository at this point in the history
please correct as necessary
  • Loading branch information
tbrowder committed Feb 15, 2017
1 parent 3363f09 commit 6c1eeab
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions doc/Language/control.pod6
Expand Up @@ -84,6 +84,26 @@ You have to watch out for this in most languages anyway to prevent things
from getting accidentally commented out. Many of the examples below may
have unnecessary semicolons for clarity.
=head1 X<while|control flow>
The C<while> block is not usually a stand-alone block since it most commonly used

This comment has been minimized.

Copy link
@timo

timo Feb 15, 2017

Contributor

you meant "when" instead of "while", right?

This comment has been minimized.

Copy link
@tbrowder

tbrowder Feb 16, 2017

Author Member

correct! corrected, thanks

inside C<given>, C<for>, and C<loop> blocks and special details of its usage in
those contexts are discussed there. However, there are a few subleties in proper
syntax of the contents inside the block's curly braces worth high-lighting.
Treat the contents pretty much as any block except for function calls. (Details are found
L<here|/language/syntax#Signature_literals>A). For example, calling a help function (C<sub help>):
=begin code
for @*ARGS {
when /:i ^ h/ { &help } # error
when /:i ^ h/ { &help; } # error
when /:i ^ h/ { &help() } # calls sub help
when /:i ^ h/ { help } # calls sub help
when /:i ^ h/ { help() } # calls sub help
when /:i ^ h/ { help(); } # calls sub help
}
=end code
=head1 X<do|control flow>
The simplest way to run a block where it cannot be a stand-alone statement
Expand Down

2 comments on commit 6c1eeab

@timo
Copy link
Contributor

@timo timo commented on 6c1eeab Feb 15, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

excuse me, but i'm not sure what this is all about ... &help and &help; are an error everywhere? it's a useless use of a sub in sink context (except of course you can get a list of values from the for loop if you want, but that's not happening in this example)

@tbrowder
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i added some comments, but this is from a working example handling args for a CLI, it's just showing six ways the help arg can be entered: 2 wrong and two correct

Please sign in to comment.