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

Behavior of bitwise ops on unencountered wide characters

Thread Next
From:
Graham Knop
Date:
June 9, 2017 09:18
Subject:
Behavior of bitwise ops on unencountered wide characters
Message ID:
CAM=m89FJ8BcgLTm8CiB_wwa9A8GPeNC2S5gVzoOMmJne06Snxw@mail.gmail.com
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.

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