Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

RE: C++ style boolean type in Perl?

by indigo (Scribe)
on Sep 28, 2000 at 22:06 UTC ( [id://34446]=note: print w/replies, xml ) Need Help??


in reply to C++ style boolean type in Perl?

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.

Replies are listed 'Best First'.
Re^2: C++ style boolean type in Perl?
by esharris (Monk) on Nov 20, 2005 at 11:32 UTC
    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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://34446]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (4)
As of 2024-04-25 18:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found