It works in C too. I was doing some research on secret operators today,
and I discovered the effects of the other inchworm-on-a-stick, and the
fact that both operators are broken for half the integers in Perl.
~- only decrements integers greater than 0 in Perl.
-~ only increments integers lesser than 0 in Perl.
According to Abigail and rgs, it's probably because ~ must also handle
strings. Abigail and I looked at the source of pp_negate, and it seems
like it does the right thing, so ~ seems to be the culprit. (I see that
tzchak Scott-Thoennes has provided a thorough answer in another mail.)
Frankly, I think this could be considered a bug. Both the left-facing
and right-facing versions of the inchworm on a stick should work on
all integers in Perl. Complement two arithmetics demand it! Now, the
question is, how long has this been broken in Perl? Forever?
--
Philippe Bruhat (BooK)
The learned man makes a mistake but once... but the truly stupid keep
practicing until they get it right.
(Moral from Groo The Wanderer #75 (Epic))