colin@array.UUCP (Colin Plumb) (07/08/90)
After getting a couple of RTFM pieces of mail, I realise I should have been more clear. I asked why Perl rejects while (EXPR); I am *not* claiming this is a valid from of the compound statement while (EXPR) BLOCK but of the modified simple statement: EXPR while (EXPR); I'm assuming that ; is of the form EXPR; It's accepted by Perl, and doesn't seem to be a declaration or a compound statement, and there is no other type of statement listed in the man page, as far as I can see, so I assume it's a simple statement, and the null string is a valid expression. Gicen this reasoning, I've found a bug in Perl, but it has a lot of assumptions, so I'm asking the experts. -- -Colin`
flee@guardian.cs.psu.edu (Felix Lee) (07/09/90)
I thought about it a bit and decided that perl doesn't have null expressions. Consider the following: sub foo { 3; ; } print &foo; If perl had null expressions, then I'd expect &foo to return an undefined value, but instead it returns 3. So I stared at perl's yacc file a bit, and lo, there is no such thing as a null expression. The "null statement" is handled in the rule that says a label can be followed by a semicolon: bar: ; and the label is optional. Adding general null expressions may make perl quite un-yaccable. I think it's enough that you can say 0 while (EXPR); or while (EXPR) {} and even while BLOCK {} -- Felix Lee flee@cs.psu.edu