> Le 18 janv. 2023 à 18:27, Kamil Tekiela <tekiela...@gmail.com> a écrit :
> 
> Strings should not be incrementable unless they are numeric strings. The
> current "feature" is more like a bug from xkcd comic. https://xkcd.com/1172/
> 
> But as there is a real need for a similar functionality, for example when
> working with Excel, I would propose to add a class into the language that
> is able to calculate and iterate any bijective base system. It needs to
> have a clear functional spec and should support both increment/decrement
> operators as well as iterators. I see this as the only way out of this
> mess. This RFC needs to pass, but it cannot pass without an alternative for
> people who actually use this "feature".

For those that lack imagination about possible use cases, here is mine: 
generating unique (in the scope of the request) alphabetic ids:

function nextid(): string {
    static $id = 'zz';
    return ++$id;
}

But no over-engineering please: no class and no decrement equivalent (the 
latter could be added in a separate RFC if it is really deemed useful), just a 
plain function that replicate the current behaviour for strings of the form 
/^[A-Za-z0-9]*$/, minus the bugs around the peculiar notion of “numeric string” 
(e.g., "9E1" equivalent to 90).

—Claude

Reply via email to