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

Re: [perl #56150] return return

Thread Next
From:
Mark Mielke
Date:
June 22, 2008 16:08
Subject:
Re: [perl #56150] return return
Message ID:
485EDB66.9020204@mark.mielke.cc
Aristotle Pagaltzis wrote:
> * Tels <nospam-abuse@bloodgate.com> [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 
C/Java.

Cheers,
mark

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 <mark@mielke.cc>


Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About