[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index][Thread Index][Top&Search][Original]

print (...) interpreted as function



This is a plea to remove the 'print (...) interpreted as function'
warning.
 
Let's look at the rational for this warning. It's to warn programmers
that if they write:
 
    print (3 + 4) * 2;
 
Perl adds 3 and 4, calls print with the result as argument, and multiplies
the result of the print with 2. Fair and square, but this unintentional
parsing can happen with all functions taking a list as argument, not just
print. However, only 'print' and 'printf' can have this warning triggered,
with other functions are save.
 
But it gets more special. The warning is only triggered if there is
exactly one space between 'print' and the opening parenthesis. 
 
    print(3 + 4) * 2;     # No 'interpreted as function' warning.
    print (3 + 4) * 2;    # 'interpreted as function' warning.
    print  (3 + 4) * 2;   # No 'interpreted as function' warning. 
 
The disadvantage of this warning is that it is also triggered at 
perfectly valid code like:
 
    print (3);
 
Therefore, I suggest we remove this warning, specially since code like:
 
    print (3 + 4) * 2;
 
already issues a warning "Useless use of multiplication (*) in void context",
regardless of the amount of whitespace between 'print' and the opening
parenthesis.
 

Abigail


Follow-Ups from:
Rafael Garcia-Suarez <raphel.garcia-suarez@hexaflux.com>
Michael G Schwern <schwern@pobox.com>
Abigail <abigail@abigail.nl>

[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index][Thread Index][Top&Search][Original]