develooper Front page | perl.perl5.porters | Postings from July 2017

Re: [perl #78288] ref and other ops are inefficient in booleancontext

Thread Previous | Thread Next
Dave Mitchell
July 28, 2017 11:35
Re: [perl #78288] ref and other ops are inefficient in booleancontext
Message ID:
On Thu, Jul 27, 2017 at 04:22:47PM -0700, Father Chrysostomos via RT wrote:
> On Thu, 27 Jul 2017 16:14:18 -0700, sprout wrote:
> > On Thu, 27 Jul 2017 03:50:56 -0700, davem wrote:
> > > A downside of &PL_sv_zero is that if assigned to a variable, that
> > > variable
> > > gets int, num and string values rather than just an int value.
> > 
> > Why does that need to be the case?  Why cannot PL_sv_zero have just
> > the SvIOK flag on?

because the first time you do, e.g.

    say "size=" . @a;

PL_sv_zero gets upgraded to an SvPOK() PVIV  anyway.

> > Does it matter that \(%h && $foo) now returns a reference to a read-
> > only value when %h is empty?  (If so, that can be solved by turning on
> > PADTMP on PL_sv_zero.)
> I think it does matter.  grep(1,@list_with_one_item) returning a mutable
> 1 and grep(1,@list_with_zero_items) returning a read-only variable is
> the kind of icky inconsistency that I tried hard to eliminate.

Won't setting PADTMP cause PL_sv_zero's PVX buffer to be stolen? Or is
that not done on a R/O var?

A walk of a thousand miles begins with a single step...
then continues for another 1,999,999 or so.

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