develooper Front page | perl.perl5.porters | Postings from June 2008

Re: [perl #56150] return return

Thread Next
Mark Mielke
June 22, 2008 16:08
Re: [perl #56150] return return
Message ID:
Aristotle Pagaltzis wrote:
> * Tels <> [2008-06-20 23:05]:
>> Also, I'd like to add that "return" at the end of a function is
>> almost always pointless, too.
> Programs should be written for people to read and only
> incidentally for machines to execute.

If your suggestion is that "return" improves readability, I disagree 
that the addition of "return" will universally improve the ability for a 
person to read the code. The "return" is more than just verbosity - it 
is a different statement with different behaviour.

Perl programmers *must* be accustomed to code blocks returning the last 
value. This is how grep and map work. Any Perl programmer that cannot 
read this comfortably will have problems with these basic functions. If 
the programmer needs an explicit "return" to tell them what is 
happening, I would suggest it isn't about machine vs people but Perl vs 


P.S. That said - there are a lot of C/Java programmers out there, and 
I've been forced to use 'return' more liberally throughout my code, as 
the C/Java programmers just don't seem to be able to get it...

Mark Mielke <>

Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About