[PROPOSAL] Alphanumeric decrement

From: Date: Thu, 12 Dec 2013 20:02:17 +0000
Subject: [PROPOSAL] Alphanumeric decrement
Groups: php.internals 
Request: Send a blank email to internals+get-70607@lists.php.net to get a copy of this message
Good evening, At present, it's possible to increment (++) an alphanumeric string, such that "a" when incremented becomes "b", "z" becomes "aa", and so on. However, it's irritated me that the same is not true for the decrement (--) operator. At present, "aa" when decremented stays as "aa", and "b" when decremented stays as "b". This lack of symettry is counterintuitive to me. I don't think it's what you would expect here. So I've written a patch which would change this. "aa" when decremented would be "z", and "b" when decremented would be "a". It also handles decrementing "a", which becomes "0". This creates an interesting new asymettry: {$a = "a"; $a--; $a++;} will result in $a being integer 1. I think it's better than the previous behaviour, though, which resulted in "b". The diff is here: https://github.com/TazeTSchnitzel/php-src/compare/php:PHP-5.6...AlphanumericDecrement My aim is to try and get this into PHP 5.6, if people are interested. Thoughts? -- Andrea Faulds http://ajf.me/

« previous php.internals (#70607) next »