develooper Front page | perl.perl5.porters | Postings from August 2010

Re: [PATCH] Re: [perl #20661] Constant strings representing a number can BECOME numbers

Thread Previous
From:
Father Chrysostomos
Date:
August 8, 2010 12:31
Subject:
Re: [PATCH] Re: [perl #20661] Constant strings representing a number can BECOME numbers
Message ID:
F78D0C0E-C2F6-4905-80E2-B457B3B66826@cpan.org

On Aug 1, 2010, at 2:22 PM, Father Chrysostomos wrote:

> I believed the attached patch is self-explanatory.
> <open_nKvdUEYU.txt>

Someone pointed out to me that it would likely be reviewed more quickly if I provided a commit message, so here it is:

This patch solves the problem of $x & "+0" not treating the RHS as a string if, on a previous invocation, the LHS happened to be a number (similarly with the other bitwise ops, too). This patch takes the conservative approach of fixing *just* those cases that have explicit quotation marks in the source code, which are clearly broken (and also ‘use constant’-style string constants, which are indistinguishable). (Read-only variables are slightly controversial still, and my patch does not affect those.)

It does this by making the appropriate pp_ funcitons look at the op tree to see whether either operand is a constant during a numeric bitwise operation. If it is, and it is not numeric, it turns off the numericness (numericality?) before returning.


Thread Previous


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About