Skip to content

Commit a72b152

Browse files
committed
Hopefully improve SUB-MAIN-OPTS doc
1 parent 1f2799d commit a72b152

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

doc/Language/functions.pod6

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -877,17 +877,22 @@ call L<exit|https://docs.perl6.org/routine/exit>.
877877
=head2 C<%*SUB-MAIN-OPTS>
878878
879879
It's possible to alter how arguments are processed before they're passed
880-
to C<sub MAIN {}> by setting options in C<%*SUB-MAIN-OPTS> hash. Available
881-
options are:
882-
883-
=head3 C<named-anywhere>
884-
885-
(my %*SUB-MAIN-OPTS)<named-anywhere> = True;
880+
to C<sub MAIN {}> by setting options in C<%*SUB-MAIN-OPTS> hash. Due to the
881+
nature of dynamic variables, one needs to set up its own C<%*SUB-MAIN-OPTS>
882+
hash and fill it with the appropriate settings. For instance:
883+
884+
my %*SUB-MAIN-OPTS =
885+
:named-anywhere, # allow named variables at any location
886+
:!foo, # don't allow foo
887+
;
886888
sub MAIN ($a, $b, :$c, :$d) {
887889
say "Accepted!"
888890
}
889891
890-
I«Note the use of parentheses around C<(my %*SUB-MAIN-OPTS)>».
892+
Available options are:
893+
894+
=head3 C<named-anywhere>
895+
891896
By default, named arguments to the program cannot be given after any positional
892897
arguments are specified. However, if C«%*SUB-MAIN-OPTS<named-anywhere>» is
893898
set to a truthy value, named arguments can be specified anywhere, even after

0 commit comments

Comments
 (0)