develooper Front page | perl.perl5.porters | Postings from September 2012

[perl #114786] EXISTS and SCALAR return values are treated differently

Thread Previous | Thread Next
Father Chrysostomos via RT
September 7, 2012 10:03
[perl #114786] EXISTS and SCALAR return values are treated differently
Message ID:
On Fri Sep 07 09:24:56 2012, baxter.brad wrote:
> This is a bug report for perl from,
> generated with the help of perlbug 1.39 running under perl 5.16.1.
> -----------------------------------------------------------------
> [Please describe your issue here]
> Once upon a time, exists() returned the true value that EXISTS()
> returned, and I found a way to make use of that (beyond true/false).
> When that changed, I changed my program, so I'm not reporting that
> as a bug.  But it got me looking and I found that scalar %hash
> returns the true/false value that SCALAR() returns instead of perl's
> true/false (1/"") which is what EXISTS() returns.
> This doesn't break any of my code.  I'm reporting for two reasons:
> 1. I think it would be good for perl to be consistent, i.e., if
>    the return value of EXISTS() is changed to 1/"" then so should
>    that of SCALAR() (and others?)

Currently scalar(%untied_hash) returns 0 (not "") for an empty hash and
bucket allocation statistics (e.g., "3245/5678"), for non-empty hashes.

However, there is talk about making it return a simple boolean, for

If we don’t make that change, then what you propose would not be
appropriate.  If we do, then, er, I don’t know.


Father Chrysostomos

via perlbug:  queue: perl5 status: new

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About