Skip to content

Commit

Permalink
make MAIN more robust and less magic
Browse files Browse the repository at this point in the history
The problem with the previous approach was that it made the parsing
of command lines dependent on the signature of each multi MAIN
candidate, making it impossible to first process @*ARGS and then
do a multi dispatch.

A different approach at fixing that would be to use the signature of
the proto of MAIN as reference instead. If somebody feels strongly
about preserving the old magic, please revert this commit and clarify
that magic command line parsing needs an explicit proto MAIN.
  • Loading branch information
moritz committed Aug 8, 2011
1 parent e874ee4 commit 5f35620
Showing 1 changed file with 2 additions and 10 deletions.
12 changes: 2 additions & 10 deletions S06-routines.pod
Original file line number Diff line number Diff line change
Expand Up @@ -3328,22 +3328,18 @@ as follows:
# Short names
-n :name
-n=value :name<value>
-nvalue :name<value> # only if not declared Bool
-n="spacey value" :name«'spacey value'»
-n='spacey value' :name«'spacey value'»
-n=val1,'val 2',etc :name«val1 'val 2' etc»

# Long names
--name :name # only if declared Bool
--name=value :name<value> # don't care
--name value :name<value> # only if not declared Bool
--name :name
--name=value :name<value>

--name="spacey value" :name«'spacey value'»
--name "spacey value" :name«'spacey value'»
--name='spacey value' :name«'spacey value'»
--name 'spacey value' :name«'spacey value'»
--name=val1,'val 2',etc :name«val1 'val 2' etc»
--name val1 'val 2' etc :name«val1 'val 2' etc» # only if declared @
-- # end named argument processing

# Negation
Expand Down Expand Up @@ -3412,10 +3408,6 @@ then you could invoke the program with either C<-f> or C<--frompart>
to specify the first parameter. Likewise you could use either C<-t>
or C<--topart> for the second parameter.

If a switch of the form C<-abc> cannot be matched against any
particular parameter, an attempt will be made to match it as if it
had been written C<-a -b -c>.

=head2 Relationship of MAIN routine with lexical setting

The preceding section describes the use of C<MAIN> in the user's code.
Expand Down

0 comments on commit 5f35620

Please sign in to comment.