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

Re: Behavior of bitwise ops on unencountered wide characters

Thread Previous | Thread Next
From:
Karl Williamson
Date:
June 9, 2017 15:25
Subject:
Re: Behavior of bitwise ops on unencountered wide characters
Message ID:
ea89770b-635e-fe2e-99e4-7b42ba1937bb@khwilliamson.com
On 06/09/2017 03:17 AM, Graham Knop wrote:
> Bitwise operations on wide characters have been deprecated since 5.24,
> and issue a warning.  This has been changed to be fatal in blead.
> However, the change that is currently in place will die in places that
> previously didn't get the deprecation warning at all.  If one of the
> strings in a bitwise operation is shorter than where the wide
> characters exist in the other, no warning would be issued.  The
> resulting string would either stop at the length of the shorter string
> for &, or have the remaining characters copied unmodified from the
> longer string for ^ and |.
> 
> For example:
> perl -we' my $f = "" & "\x{ABCD}" '
> 
> This will not warn on 5.26, but is fatal in blead.  The change was
> introduced in 08b6664b858b8fd4b5c0c27542763337b6d78e46.
> 
> This breaks code that I'm using, including newer versions of JSON::PP.
> The reason I'm using this is admittedly an abuse of the bitwise ops
> for number detection.  The result of ($var ^ "") can tell you the
> status of the internal flags for a if value is a valid number, which
> is needed for serialization.  The alternative is using B to examine
> the flags, which is significantly slower.
> 
> Doing operations like this doesn't run into the problems motivating
> the removal of bitwise ops on wide characters, so I would vote for
> restoring support for it.  If that is not an option, there at least
> needs to be a release cycle with a deprecation warning for this.
> 

I think it is correct to allow the & case where the non-downgradable 
characters don't figure in the output.

I agree that blead needs to change to handle the | and ^ cases so the 
result of the operation is unchanged from previous releases.  I don't 
know if this usage should be deprecated or not.  I look forward to 
seeing discussion concerning that.

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