Re: [RFC] Define proper semantics for range() function
| From: | G. P. B. | Date: | Tue, 16 May 2023 12:29:41 +0000 |
| Subject: | Re: [RFC] Define proper semantics for range() function | ||
| References: | 1 2 3 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-120310@lists.php.net to get a copy of this message | ||
On Mon, 15 May 2023 at 23:53, Jorg Sowa <jorg.sowa@gmail.com> wrote:
> Hello!
>
> I have one concern about the part:
>
> > Emit an E_WARNING when $start or $end is cast to an integer because the
> other boundary input is a number or numeric string. (e.g. range
> <http://www.php.net/range>('5', 'z');
> or range <http://www.php.net/range>(
> 5, 'z');)
>
> Doesn't it limit the functionality of the function for the numbers as
> characters? Currently when we call range('/','z') we get full range of
> characters. https://onlinephp.io/c/9cb12
>
> But when we change argument $start to next character which is zero ('0')
> then we get array with only one element.
> https://onlinephp.io/c/a0cda
>
> Casting numerical string in this function may be confusing.
>
> Sorry for making fuss just before voting, but didn't see this topic before
> and wanted to share my insights with you thinking it may be relevant.
>
No worries, this is the point of giving a heads-up.
Someone else brought this to my attention again as well.
And the concern makes sense, I've updated the implementation and RFC to
adjust the behaviour with string digits:
https://wiki.php.net/rfc/proper-range-semantics
Please let me know if this addresses the issue and is also clear.
Best regards,
George P. Banyard