Re: [RFC] Define proper semantics for range() function
| From: | Jorg Sowa | Date: | Tue, 16 May 2023 16:49:35 +0000 |
| Subject: | Re: [RFC] Define proper semantics for range() function | ||
| References: | 1 2 3 4 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-120317@lists.php.net to get a copy of this message | ||
Thank you. That makes sense. I have last question about case with integer
and string digit, i.e. range('5', 10) or range('1', 9). What would be in
this case expected output? I couldn't find any test cases covering this
example.
Kind regards,
Jorg
On Tue, May 16, 2023 at 2:29 PM G. P. B. <george.banyard@gmail.com> wrote:
> 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
>
>
>
>