develooper Front page | perl.perl6.language | Postings from August 2010

r31976 -[S06] make MAIN short switches a bit saner

From:
pugs-commits
Date:
August 13, 2010 02:32
Subject:
r31976 -[S06] make MAIN short switches a bit saner
Message ID:
20100813093238.4189.qmail@feather.perl6.nl
Author: moritz
Date: 2010-08-13 11:32:37 +0200 (Fri, 13 Aug 2010)
New Revision: 31976

Modified:
   docs/Perl6/Spec/S06-routines.pod
Log:
[S06] make MAIN short switches a bit saner

The variable name of a parameter is purely an implementation detail
of the subroutine, and shouldn't be a concern while parsing command line
arguments. Instead rely on already existing alias syntax for named parameters.

Modified: docs/Perl6/Spec/S06-routines.pod
===================================================================
--- docs/Perl6/Spec/S06-routines.pod	2010-08-13 09:03:22 UTC (rev 31975)
+++ docs/Perl6/Spec/S06-routines.pod	2010-08-13 09:32:37 UTC (rev 31976)
@@ -3279,11 +3279,12 @@
 there's no particular reason the sub has to be named C<MAIN>.
 
 To give both a long and a short switch name, you may use the pair
-notation.  The key will be considered the short switch name, while
-the variable name will be considered the long switch name.  So if
-the previous declaration had been:
+notation to install several names for the same parameter.
+If any of the names is a single character, it will be considered a
+short switch name, while all other parameters names are considered
+as long switch name.  So if the previous declaration had been:
 
-    sub MAIN (:f($frompart), :t($topart), *@rest)
+    sub MAIN (:f(:$frompart), :t(:$topart), *@rest)
 
 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>




nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About