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

Sendu Bala sb at mrc-dunn.cam.ac.uk
Wed May 31 14:56:49 UTC 2006


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;

The bioperl docs will typically explicitly state that undef is returned, 
and under what circumstance. If a user suffers from the 
undef-into-array-problem, yes it can be slightly unexpected, but lots of 
unexpected things will happen when you don't use a method correctly, as 
per the docs!

Fixing the return of undef is either a job that shouldn't be done, or a 
much harder job than expected.



More information about the Bioperl-l mailing list