Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: Hope a subroutine will return undef by default

by Jenda (Abbot)
on Feb 11, 2014 at 23:58 UTC ( #1074549=note: print w/ replies, xml ) Need Help??


in reply to Hope a subroutine will return undef by default

What if instead of trying to bend Perl to be like ... well ... what language are you actually trying to mimic here? ... what if instead you just got used to Perl being Perl? I can understand a code policy requiring an explicit return statement ensured either by code review or (if such thing is possible) using Perl::Critic, but no matter what way you do it this is only ever gonna cause confusion and pain. I'm pretty sure you could do something using source code filters or somesuch hackery, but you really do not want to do that!

Jenda
Enoch was right!
Enjoy the last years of Rome.


Comment on Re: Hope a subroutine will return undef by default
Re^2: Hope a subroutine will return undef by default
by LanX (Canon) on Feb 12, 2014 at 01:00 UTC
    > what language are you actually trying to mimic here?

    At least Javascript comes to mind (update: and Python)

    Cheers Rolf

    ( addicted to the Perl Programming Language)

      You are right, javascript does this. "return ;" in the middle of a function has the same return value as the case when execution of the function goes the end of the function body without a return statement --- both cases return "undefined" or null. No surprises.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (6)
As of 2014-08-23 06:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (172 votes), past polls