[Omaha.pm] short is good

Dan Linder dan at linder.org
Thu Apr 22 06:51:12 PDT 2010


Maybe it's my old brain, but I like using "return" in this context for code
that isn't being submitted to a PerlGolf competition.

I've encountered enough bad/sketchy coding that didn't define a return value
for a subroutine that I would be suspicious if the original programmer
/meant/ to return the $self->send() value, or if they thought they were
calling some other routine (and the return value was just a
by-product/accident).

Golf is great, but it isn't always productive.  (Much like "real golf".)

DanL

2010/4/21 Theodore Katseres <tedkat at gmail.com>

> 2010/4/20 Jay Hannah <jhannah at omnihotels.com>
>
>  laugh... caught myself changing code to this
>>
>>
>>
>>    my $response;
>>
>>    unless ( $response = $self->send() ) {
>>
>>      return 0;
>>
>>    }
>>
>>    return $response;
>>
>>
>>
>> this is much better:
>>
>>
>>
>>    return $self->send();
>>
>
> For some extra GOLF points you could
>
> {
>  ...
>   $self->send();
> }
>
> --
> Ted Katseres
>      ||=O=||
>
> _______________________________________________
> Omaha-pm mailing list
> Omaha-pm at pm.org
> http://mail.pm.org/mailman/listinfo/omaha-pm
>



-- 
***************** ************* *********** ******* ***** *** **
"Quis custodiet ipsos custodes?"
   (Who can watch the watchmen?)
   -- from the Satires of Juvenal
"I do not fear computers, I fear the lack of them."
   -- Isaac Asimov (Author)
** *** ***** ******* *********** ************* *****************
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.pm.org/pipermail/omaha-pm/attachments/20100422/47638aef/attachment.html>


More information about the Omaha-pm mailing list