Larry Wall wrote: > I think we also need to fix this: > > print (length $a), "\n"; > > The problem with Perl 5's rule, "If it looks like a function, it *is* > a function", is that the above doesn't actually look like a function > to most people.
Yup, definitely. This is one of the things that is most awkward about teaching Perl 5 beginners. It isn't nice to have to explain the intricacies of this right at the beginning of the course, but not doing so leads to people getting caught by it and not realizing why. > I'm thinking we need a rule that says you can't put a space before a > dereferencing (...), I'm concerned that making this sensitive to whitespace doesn't simplify things. > print(length $a), "\n"; > print (length $a), "\n"; Those look to me like they should do the same thing as each other. Distinguishing them sounds scary, much scarier than having C<$a _ 1> being different from C<$a_1>. How much is the 'if it looks like a function it is a function' rule needed at all? What would be the harm in not having any special rule here, so both of the above pass the line-break to C<print>? Somebody needing to ensure that C<print> only got one argument could do: (print length $a), "\n"; That is, parens always go round the outside of the thing they are grouping even when the thing is a function call. That would be counter-intuitive to anybody coming from a background in a language where parens have to be used in all function calls, but: 1 It has the benefit of there being one simple rule to learn, with no caveats about functions (or whitespace). Even when somebody gets it wrong, it's a case of showing how the general rule should be applied in this particular case rather than introducing an exception; that should be easier to learn. 2 There's no need to have any sort of disambiguating character (like the current C<+> or the suggested C<.> (with opposite meanings)). 3 If somebody wants to put parens after all her/his function names they often won't do any harm. I don't think the default situation for somebody who doesn't know the rules is made worse. There are some situations made 'worse', and some, like the above, made 'better'. Smylers