[Bioperl-l] For CVS developers - potential pitfallwith "returnundef"
Lincoln Stein
lstein at cshl.edu
Wed May 31 18:14:59 UTC 2006
If the documentation says "returns false" then I expect to be able to do this:
@result = foo();
die "foo() failed" unless @result;
If the documentation says "returns undef" then I expect this:
@result = foo();
die "foo() failed" unless $result[0];
Lincoln
On Wednesday 31 May 2006 14:08, Hilmar Lapp wrote:
> On May 31, 2006, at 12:03 PM, Lincoln Stein wrote:
> > If the subroutine is documented to return "false" on failure, then
> > one must call
> > return (or "return ()" ).
>
> The problem seems to be that 'a value that evaluates to either true
> or false' and 'a [meaningful] value or undef' and 'a value or
> false' ('a value or no value) are not the same in perl. And what
> would/should one expect if the doc states 'true on success and false
> otherwise'?
>
> Maybe the documentation should also be fixed to avoid any ambiguity.
> I.e., avoid documenting 'a value or false' because it may be
> ambiguous (not only) to the less proficient. 'True or false' should
> imply a value being returned.
>
> Comments?
>
> -hilmar
--
Lincoln D. Stein
Cold Spring Harbor Laboratory
1 Bungtown Road
Cold Spring Harbor, NY 11724
(516) 367-8380 (voice)
(516) 367-8389 (fax)
FOR URGENT MESSAGES & SCHEDULING,
PLEASE CONTACT MY ASSISTANT,
SANDRA MICHELSEN, AT michelse at cshl.edu
More information about the Bioperl-l
mailing list