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

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

Thread Previous | Thread Next
From:
Father Chrysostomos via RT
Date:
September 7, 2012 10:03
Subject:
[perl #114786] EXISTS and SCALAR return values are treated differently
Message ID:
rt-3.6.HEAD-11172-1347037417-948.114786-15-0@perl.org
On Fri Sep 07 09:24:56 2012, baxter.brad wrote:
> This is a bug report for perl from bmb@mail.libs.uga.edu,
> 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
efficiency.

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
https://rt.perl.org:443/rt3/Ticket/Display.html?id=114786

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