Re: [RFC] [VOTE] Define proper semantics for range() function
| From: | Marc | Date: | Thu, 08 Jun 2023 06:35:00 +0000 |
| Subject: | Re: [RFC] [VOTE] Define proper semantics for range() function | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-120538@lists.php.net to get a copy of this message | ||
On 01.06.23 18:16, G. P. B. wrote:
Hello internals, The vote for the Define proper semantics for range() function RFC is now open and will last for two weeks until the 15th of June 2023: https://wiki.php.net/rfc/proper-range-semantics Best regards, George P. Banyard Hi George,sorry for speaking up so late but I think the following change is a mistake and unexpected:
Calls to range() that have integer boundaries but a float step that is compatible as an integer will now return an array of integers instead of an array of floats:var_dump( range(1, 5, 2.0) ); /* New Behaviour */ array(3) { [0]=> int(1) [1]=> int(3) [2]=> int(5) } /* Current Behaviour */ array(3) { [0]=> float(1) [1]=> float(3) [2]=> float(5) } The problem I see with this is that the return type changes from float to int "magically" based on the value of the step. range(1, 5, 2.0) // list<int> range(1, 5, 2.1) // list<float> In my opinion, no matter, if start, end or step is a float the result should be a list<float>. Thanks, Marc