rfc:proper-range-semantics
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionLast revisionBoth sides next revision | ||
rfc:proper-range-semantics [2023/05/08 14:31] – Fix grammar in several places theodorejb | rfc:proper-range-semantics [2023/06/15 14:47] – Close vote girgias | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== PHP RFC: Define proper semantics for range() function | ====== PHP RFC: Define proper semantics for range() function | ||
- | * Version: 0.2 | + | * Version: 0.3 |
* Date: 2023-03-13 | * Date: 2023-03-13 | ||
* Author: George Peter Banyard, < | * Author: George Peter Banyard, < | ||
- | * Status: | + | * Status: |
* Target Version: PHP 8.3 | * Target Version: PHP 8.3 | ||
* Implementation: | * Implementation: | ||
Line 19: | Line 19: | ||
The current behaviour is quite complex, and it might be easier to just read the implementation, | The current behaviour is quite complex, and it might be easier to just read the implementation, | ||
- | First, check if the < | + | First, check if the < |
Then check the boundary arguments: | Then check the boundary arguments: | ||
Line 132: | Line 132: | ||
[4] | [4] | ||
string(1) " | string(1) " | ||
+ | } | ||
+ | |||
+ | |||
+ | var_dump(range(' | ||
+ | array(3) { | ||
+ | [0]=> | ||
+ | int(1) | ||
+ | [1]=> | ||
+ | int(2) | ||
+ | [2]=> | ||
+ | int(3) | ||
} | } | ||
</ | </ | ||
Line 341: | Line 352: | ||
Where using a NAN value as a step even breaks the expectation that < | Where using a NAN value as a step even breaks the expectation that < | ||
+ | ==== Issues surrounding usage of string digits ==== | ||
+ | |||
+ | If one of the boundary inputs is a string digit (e.g. ''" | ||
+ | This doesn' | ||
+ | |||
+ | However, if the other input is a non-numeric string the expected behaviour of generating a list of ASCII characters is not upheld anymore: | ||
+ | <PHP> | ||
+ | var_dump( range(" | ||
+ | array(10) { | ||
+ | [0]=> | ||
+ | int(9) | ||
+ | [1]=> | ||
+ | int(8) | ||
+ | [2]=> | ||
+ | int(7) | ||
+ | [3]=> | ||
+ | int(6) | ||
+ | [4]=> | ||
+ | int(5) | ||
+ | [5]=> | ||
+ | int(4) | ||
+ | [6]=> | ||
+ | int(3) | ||
+ | [7]=> | ||
+ | int(2) | ||
+ | [8]=> | ||
+ | int(1) | ||
+ | [9]=> | ||
+ | int(0) | ||
+ | } | ||
+ | </ | ||
+ | instead of the expected: | ||
+ | <PHP> | ||
+ | var_dump( range(" | ||
+ | array(9) { | ||
+ | [0]=> | ||
+ | string(1) " | ||
+ | [1]=> | ||
+ | string(1) ":" | ||
+ | [2]=> | ||
+ | string(1) ";" | ||
+ | [3]=> | ||
+ | string(1) "<" | ||
+ | [4]=> | ||
+ | string(1) " | ||
+ | [5]=> | ||
+ | string(1) ">" | ||
+ | [6]=> | ||
+ | string(1) "?" | ||
+ | [7]=> | ||
+ | string(1) " | ||
+ | [8]=> | ||
+ | string(1) " | ||
+ | } | ||
+ | </ | ||
===== Proposal ===== | ===== Proposal ===== | ||
Line 355: | Line 421: | ||
* Emit an < | * Emit an < | ||
* Emit an < | * Emit an < | ||
- | * Emit an < | + | * Emit an < |
- | * Emit an < | + | * Produce a list of characters if one of the boundary inputs is a string digit instead of casting the other input to int (e.g. < |
+ | * Emit an < | ||
Line 375: | Line 442: | ||
[4]=> | [4]=> | ||
string(1) " | string(1) " | ||
+ | } | ||
+ | |||
+ | var_dump( range(" | ||
+ | array(9) { | ||
+ | [0]=> | ||
+ | string(1) " | ||
+ | [1]=> | ||
+ | string(1) ":" | ||
+ | [2]=> | ||
+ | string(1) ";" | ||
+ | [3]=> | ||
+ | string(1) "<" | ||
+ | [4]=> | ||
+ | string(1) " | ||
+ | [5]=> | ||
+ | string(1) ">" | ||
+ | [6]=> | ||
+ | string(1) "?" | ||
+ | [7]=> | ||
+ | string(1) " | ||
+ | [8]=> | ||
+ | string(1) " | ||
} | } | ||
Line 467: | Line 556: | ||
As per the voting RFC a yes/no vote with a 2/3 majority is needed for this proposal to be accepted. | As per the voting RFC a yes/no vote with a 2/3 majority is needed for this proposal to be accepted. | ||
- | Voting started on 2023-XX-XX and will end on 2023-XX-XX. | + | Voting started on 2023-06-01 and will end on 2023-06-15. |
<doodle title=" | <doodle title=" | ||
* Yes | * Yes |
rfc/proper-range-semantics.txt · Last modified: 2023/06/19 13:41 by girgias