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

[perl #78288] ref and other ops are inefficient in boolean context

Thread Previous | Thread Next
From:
Father Chrysostomos via RT
Date:
July 27, 2017 23:14
Subject:
[perl #78288] ref and other ops are inefficient in boolean context
Message ID:
rt-4.0.24-31582-1501197258-1486.78288-15-0@perl.org
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?

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.)

> Also, index() doesn't return a boolean value, but for no match it
> returns
> -1. So for code like
> 
> if (index(...) != -1) { ... }
> 
> optimise away the OP_CONST and the OP_EQ and flag the index op to
> return a
> boolean value.

index(...) >= 0 is also quite common.

-- 

Father Chrysostomos


---
via perlbug:  queue: perl5 status: open
https://rt.perl.org/Ticket/Display.html?id=78288

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