We've also put in an escape hatch for when you really need whitespace there. A subscript or argument list can be detached if you put a dot in front of it:
print .($bar)
%foo .{'bar'}
@abc .[123]
In theory, we could require no whitespace before ++ too, but we don't actually need to unless someone defines a binary operator ++, whereupon the correct response is to shoot them. | [reply] [d/l] [select] |
The closest example to this that I've run into is extremely close. When Perl changed the interpretation of "print (" to be the same as "print(", I found that the problems clearly increased, and stayed up even long after the change. So I enthusiastically support Perl6's idea to not allow whitespace in a few key places where whitespace has no good reason to be.
When was that, in the perl4 era? As far as I can remember, print has behaved the same as any other function, allowing you
to have whitespace between the function name and the opening parenthesis - except that 'print' will whine if you actually use parenthesis (if you have warnings turned on, and haven't disabled the warning).
$ cat tye
print (3 + 4) * 5; print "\n";
print(3 + 4) * 5; print "\n";
$ /opt/perl/5.000/bin/perl tye
7
7
$
If it was different in perl4, then I'm sure glad that in perl5 we don't have exceptions in the parsing of functions/arguments depending on the function name.
Note that in perl1 different results are printed - but at least they are consistent:
$ /opt/perl/1.0.0/bin/perl tye
35
35
$
Putting whitespace between a hash and the '{' makes as much sense to me as wanting to write "10 . 45 e - 12" because it is "easier to read" (no, actually wanting spaces in some numbers makes more sense to me)
Well, you can't put spaces inside numbers (for more or less obvious reasons), but Perl does have an alternative: it allows you to put underscores in numbers - for exactly that: better readability. Putting a space between the name of an aggragate and its index makes as much sense to me as to separate an adjective from a noun in an English sentence. $hash {index} is an operation (a mapping in this case) with two operands: a hash, and a string. A function call is also a mapping, but with a variable number of arguments. How do you call a function with say 5 arguments (say, a push of four elements on an array)? Do you call it like:
push@array,"second","third","fourth","fifth";
Or do you put in some whitespace? And if one puts in whitespace, then why not put whitespace between the name of the function and the first argument?
Oh well, at least this will cause the Python people to have a field day. They always got laughed at (often by Perl folks) for their "whitespace rules". And now we got perl6. At least in Python, the whitespace rules are sane.
Abigail | [reply] [d/l] [select] |