Re: [VOTE] [RFC] Alphanumeric Decrement
On 21 January 2014 20:47, Lars Strojny <lars@strojny.net> wrote:
> I would rather introduce a deprecation warning for decrementing (and
> incrementing) alphanumeric strings. It’s just very bad behaviour and using
> chr() and ord() is not that hard :)
Agreed that the *current* behaviour is very bad and not hugely useful.
Being able to increment and decrement "strings" is, however, often
useful behaviour when dealing with binary data, and chr()/ord() can be
expensive in this scenario.
I would like to have something closer to C's behaviour, where (given
that in PHP a string is essentially just a char*) I can access a
character in a string by index (returns a string) and manipulate it
arithmetically - so inc/dec would alter the byte value by 1, over the
full range 0-255. If this were the case, I would expect an inc/dec
operation on a string >1 character to apply the operation to the first
character in the string, and operating on an empty string would
produce an E_NOTICE.
I would hate to see a deprecation warning issued now if it's possible
the behaviour could be made more sensible in the future and
"undeprecated".
Obviously this kind of BC-break would be for a new major version, I'm
not suggesting this is done immediately.
For the record, this also sums up why I have voted "no" on the current
RFC - I don't want to introduce more counter-intuitive behaviour when
there is a much more intuitive (and useful) alternative.
Thanks, Chris
Thread (19 messages)