Re: [rfc] normalize increment and decrement operators

From: Date: Sat, 15 Feb 2014 02:26:51 +0000
Subject: Re: [rfc] normalize increment and decrement operators
References: 1  Groups: php.internals 
Request: Send a blank email to [email protected] to get a copy of this message


On 15/02/14 02:12, Tjerk Meesters wrote:
Following the earlier discussion of adding decrement for strings to complement the existing alphanumeric increment feature, I've written a proposal to normalize the behaviour across boolean and null values. https://wiki.php.net/rfc/normalize_inc_dec Based on some earlier comments, boolean and null values can be treated in two distinct way, both of which are demonstrated in the rfc; I'm hoping that before voting takes place we can eliminate one voting option altogether. It also aims to deprecate string-based increments using ++; instead, it would introduce str_inc() and str_dec() as a regular function. Let me know your thoughts.
I actually already wrote a patch for removing alphanumeric increment and decrement, if you're interested: https://github.com/TazeTSchnitzel/php-src/tree/AlphanumericIncrement Personally, I think the sanest solution is to increment number-looking strings as if they were numbers ("0" becomes 1), increment numbers (obviously), and throw a warning and do nothing for everything else. Though it would be best if the $a++ behaviour matches $a += 1 and $a = $a + 1. So, while I'd prefer the strict approach I just mentioned, we should actually make it function identically to the other ways of incrementing. -- Andrea Faulds http://ajf.me/

Thread (2 messages)

« previous php.internals (#72622) next »