Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re^3: What could make "()" a good value for boolean false?

by ikegami (Patriarch)
on Mar 31, 2016 at 02:58 UTC ( [id://1159174]=note: print w/replies, xml ) Need Help??


in reply to Re^2: What could make "()" a good value for boolean false?
in thread What could make "()" a good value for boolean false?

I hope not, because I'm opposed to it. Sub that are expected to return a scalar shouldn't suddenly return nothing. It causes subtle problems that aren't caught by the compiler.

Consider what happens if type suddenly returned nothing instead of `undef`:

my $h = { type => type(), name => name(), };

return (); should be used for subs that are expected to return a list.

return undef; should be used for subs that are expected to return a scalar. There are exceptions, of course.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (6)
As of 2024-04-18 02:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found