develooper Front page | perl.perl5.porters | Postings from October 2003

Re: [PATCH pod/perlfunc.pod] ref can return false on references

Thread Previous | Thread Next
From:
Gisle Aas
Date:
October 6, 2003 06:43
Subject:
Re: [PATCH pod/perlfunc.pod] ref can return false on references
Message ID:
lrad8ea3fj.fsf@caliper.activestate.com
Abigail <abigail@abigail.nl> writes:

> The first sentence of 'perldoc -f ref' is wrong:
> 
>     Returns a true value if EXPR is a reference, false otherwise.
> 
> To wit:
> 
>     $ perl -wle 'print ref bless [] => 0'
>     0
> 
> Patch follows.
> 
> 
> Abigail
> 
> --- pod/perlfunc.pod.orig       Mon Oct  6 14:45:36 2003
> +++ pod/perlfunc.pod    Mon Oct  6 14:46:46 2003
> @@ -3987,7 +3987,8 @@
>  
>  =item ref
>  
> -Returns a true value if EXPR is a reference, false otherwise.  If EXPR
> +Returns a non-empty string if EXPR is a reference, the empty
> +string otherwise. If EXPR
>  is not specified, C<$_> will be used.  The value returned depends on the
>  type of thing the reference is a reference to.
>  Builtin types include:

The reason this function is called ref() is because it is supposed to
be true when the argument is a reference, so I think this rewording
makes the documentation confusing.  I think it would be better to
explain this edge-case instead.  I would even consider fixing bless
instead to make the documentation true.

Regards,
Gisle

Thread Previous | 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