Um, there's no REAL need for explicit "true" and "false"
datatypes in Perl. Watch:
if (foo()) { foo() returned a true value }
if (!bar()) { bar() returned a false value }
$DEBUG = 1;
if ($DEBUG) { ... }
If you really feel the need for 'true' and 'false',
then please make this compromise with me:
use constant TRUE => 1;
use constant FALSE => 0;
# ...
$DEBUG = TRUE;
# ...
if ($DEBUG) { ... }
Please do NOT test for equality with TRUE or equality with
FALSE. They are pointless test, and broken in cases of TRUE
that aren't '1'.
$_="goto+F.print+chop;\n=yhpaj";F1:eval | [reply] [d/l] [select] |
Mostly it is useless, and it is potentially dangerous if you are used to C++ booleans. C++ has only one false value, so:
if (x == FALSE)
will work every time. However, in Perl you have:
if ($x == $false)
if ($x eq $false)
How do these work? What if $x = 0? or ''? or undef or 0.0? Are you sure?
Perl has mutliple false values, so switching to a single
false value is just asking for trouble.
Perl is perl, don't try to redefine the language. It is like the Pascal programmer who starts all his C code with:
#define BEGIN {
#define END }
Server no purpose, confusing to others, and it just begging for weird ass bugs.
| [reply] [d/l] [select] |
IMHO, adding these 2 constants in Perl is not redefining the language. The resulting script still looks like Perl. I've use these 2 constants in my scripts and I think using them enhances readability.
| [reply] |
I agree with japhy, but even constants bloat the code in the simple case of constants. That's some type of function call for every constant. | [reply] |
No, it isn't. When you use constant, Perl replaces
the constants with the values they return at compile-time.
$_="goto+F.print+chop;\n=yhpaj";F1:eval
| [reply] |