John Porter wrote:
>
> Yeah, not to mention the fact that many modules, notably CGI.pm,
> are arranged to allow to use unquoted strings of the form -name:
>
> print textfield( -name => 'description' );
Well, this one's not an issue, because => auto-quotes the LHS. It's the
same as this:
print textfield( "-name", 'description' );
Which obviously wouldn't be a problem.
> John L. Allen wrote:
> >
> > I can't believe that special-casing the token -[rwxoRWXOezsfdlpSbctugkTBMAC]+
> > is an acceptble solution. I mean think of all the existing perl keywords
> > that that already matches: -pos, -cos, -lc, -uc, -fork, -use, -pop, -exp,
> > -oct, -log, -ord + others!. A lot of these already have a legitimate
> > not-filetest meaning, others not :-)
Obviously, I wouldn't want to push incompatibility. But I personally
have never wanted to say:
$result = -exp($num);
So badly that this:
$result = - exp($num);
Would be too much of a burden. There's only a very small number of
functions where direct negation would even make sense, as you yourself
note. And a simple space or set of parens would be all you'd need.
Any type of -syntax runs the risk of these problems. For example:
-r $file; # sub r {} already broken
-rwx $file; # now many more broken
-1; # still works ok
-[rwx]; # negation of an arrayref
-{rwx}; # negation of a hashref
-/rwx/; # negation of a pattern match
-(rwx); # negation of a list
-^rwx; # negation of a higher-order function
-!rwx; # negation of boolean test
-#rwx#; # negation of a comment
Basically, the - is already used as a negation symbol, which is a unary
operator and as such can be attached to anything. Perl already has a
special catch in the grammar so that these two:
$num = -1;
$str = -r;
Do not work the same. Simply make a blanket rule that -[a-zA-Z]+ is
always special. Then the documentation that says:
http://www.perl.com/pub/doc/manual/html/pod/perlfunc/_X.html
Note that -s/a/b/ does not do a negated substitution.
Saying -exp($foo) still works as expected, however--
only single letters following a minus are interpreted as
file tests.
Could be changed to:
A - following by any purely alpabetic string will not
negate that string. Saying -exp($foo) will attempt a
file test on $foo. However, saying - exp($foo) will
work as expected -- a single space is all that is
needed. Note -1 and other numbers will always work.
If we decide to extend the filetest mechanism, then we're going to run
into problems with the unary negation - no matter what syntax we choose.
I personally think that just making -string special is a simple,
consistent rule. If someone really needs to negate a string, they simply
insert a space.
However, any notation that made sense and did not introduce
incompatibility or inconsistency of some sort would be welcome.
-Nate