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:
fergal@esatclear.ie
Date:
October 6, 2003 07:18
Subject:
Re: [PATCH pod/perlfunc.pod] ref can return false on references
Message ID:
63340-220031016141745959@M2W050.mail2web.com
It might also be worth mentioning Scalar::Util's reftype() and blessed()
which are unambiguous in their functionality and often what people really
should be using mean when use ref(),

F

Original Message:
-----------------
From: Gisle Aas gisle@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


--------------------------------------------------------------------
mail2web - Check your email from the web at
http://mail2web.com/ .



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