Re: [RFC] Path to Saner Increment/Decrement operators

From: Date: Tue, 17 Jan 2023 16:28:31 +0000
Subject: Re: [RFC] Path to Saner Increment/Decrement operators
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-119295@lists.php.net to get a copy of this message
On 17 Jan 2023, at 14:28, G. P. B. <george.banyard@gmail.com> wrote: > https://wiki.php.net/rfc/saner-inc-dec-operators > > The goal of this RFC is to reduce language complexity by making $v++ behave > like $v += 1 and $v-- behave like $v -= 1; > > I am expecting the contentious part of the proposal to be the deprecation > of the PERL string increment feature to achieve the aforementioned goal. Hi George, Just to confirm, you're suggesting the following would be broken: ``` $ref = 'A'; $ref++; var_dump($ref); // 'B' $ref = 'Z'; $ref++; var_dump($ref); // 'AA' $ref++; var_dump($ref); // 'AB' ``` I've seen this used a few times, e.g. starting with a numerical value (Passport number, NHS number, Social Security Number, Date of Birth 20230117), and the developer simply appends an incrementing letter on the end to get a unique reference; e.g. a person having multiple assessments... especially if it's more than 26 (A-Z), and you need to move to multiple letters, which chr(90 + 1) cannot help you with. That said, I appreciate that incrementing some strings can be a bit unusual (e.g. "A9" to "B0", vs "A 9" to "A 0"). Craig

« previous php.internals (#119295) next »