[Bioperl-l] For CVS developers - potential pitfallwith "returnundef"

Sendu Bala sb at mrc-dunn.cam.ac.uk
Thu Jun 8 16:03:21 UTC 2006


Sendu Bala wrote:
> Heikki Lehvaslaiho wrote:
>> In my opinion the sooner the bugs get exposed the better. It is much more 
>> likely that there is a well hidden bug caused by assigning accidentally undef 
>> into an one element array that someone intentionally writing code that 
>> expects that behaviour!
>>
>> I removed (but did not commit yet) all undefs from my old Bio::Variation code 
>> and could not see any differences in the test output. 
>>
>> Let's remove them!
> 
> Just looking for all return undef;s isn't enough. It's entirely possible 
> to do something like:
> 
> my $return_value;
> {
>    # do something that assigns to return_value on success
>    # on failure, just do nothing
> }
> return $return_value;

Looks like Heikki's work went well. If there is any further interest in 
getting rid of all the remaining undef returns, this also need to be fixed:

sub x {
   # return (...) on success
   # do nothing on failure
}

Needs to be changed to:

sub x {
   # return (...) on success
   return;
}



More information about the Bioperl-l mailing list