Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
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 making s'mores by the fire in the courtyard of the Monastery: (2)
As of 2025-12-08 01:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What's your view on AI coding assistants?





    Results (87 votes). Check out past polls.

    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.