Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: Returning undef: The point I would like Damian to reconsider

by chromatic (Archbishop)
on Jun 22, 2007 at 17:37 UTC ( [id://622864]=note: print w/replies, xml ) Need Help??


in reply to Returning undef: The point I would like Damian to reconsider

An empty return statement would be a mistake there, precisely because the function might be called in list context. In Perl, list context is sometimes inconvenient to avoid, for example if an expression happens to be used as a subroutine argument. We should not expect our undef function result to vanish and be replaced by the next argument in such a situation, I think.

The only time where this would harm the code I tend to write is if I had a semi-predicate problem in a function that returned a list. (The only reason I don't run into the problem where hash declarations impose list context is that I don't do much CGI programming, where I might call $q->param( 'foo' ) in a hash assignment.)

Log In?
Username:
Password:

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

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

    No recent polls found