On 2010-05-26, at 8:52 am, Larry Wall wrote: > On Wed, May 26, 2010 at 07:22:36AM -0700, jerry gay wrote: > : On Wed, May 26, 2010 at 00:53, Moritz Lenz <[email protected]> wrote: > : > sub MAIN(:name(:$n)) > : > then $n has two names, 'name' and 'n', and we could consider all > one-letter > : > parameter names as short names
Presumably you could have :n($name) or :name($n), depending on whether you wanted to use the shorter name in your code, and either way, consider one-letter names as short. > Also, it's a bit antisocial to get people used to using certain short > switches and then cancel them out when they get ambiguous. I feel that may also apply to having -abc be able to mean -a -b -c or -a=bc. The spec doesn't give a rule, but I'd say combining short switches is the handier shortcut, and just require the = to set a value. (And again, if you need to, you can always parse the params yourself.) That does raise a question of what to do about "-vvv". Repeating a switch as a kind of incrementing is a venerable tradition, but it doesn't really get us anything more than -v=3. Also, I assume that when repeating a long name, the last use overwrites any previous uses, so to be consistent, -vvv would mean -v -v -v which would mean simply -v. In which case, is it worth giving a warning to that effect, in case the user was expecting it to mean -v=3? Another detail: the spec mentions "exact Perl 6 forms" like :name<value> or :name(value); I don't see any particular reason not to allow --name<value> or --name(value) as well. (And it's one less arbitrary difference between --name and :name.) Also, setting any value that contains a comma will get it split. If you don't want a list, you'd have to join the pieces back together (or don't use the default parsing), which seems reasonable to me. However, the splitting could also be limited to params that were declared as arrays. Finally, the spec mentions the "usual" practice of ending named params at the first positional arg. Of course, some commands continue to process named params either way. For programs like Perl itself, e.g. "perl --args --for --perl some-script.pl --args --for --script", continuing past the positional arg would not do the right thing. But is this common enough to be the default? You can always use "--" to force positional treatment, but not the other way around. -David
