rfc:explicit_octal_notation
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
rfc:explicit_octal_notation [2020/10/20 22:54] – Add a section about not supporting octal strings. girgias | rfc:explicit_octal_notation [2021/01/04 20:12] (current) – Change status to implemented and specify links girgias | ||
---|---|---|---|
Line 3: | Line 3: | ||
* Date: 2020-10-20 | * Date: 2020-10-20 | ||
* Author: George Peter Banyard, < | * Author: George Peter Banyard, < | ||
- | * Status: | + | * Status: |
* First Published at: https:// | * First Published at: https:// | ||
===== Introduction ===== | ===== Introduction ===== | ||
- | PHP's literal octal notation can lead to some confusing results such as <php>" | + | |
+ | PHP's literal octal notation can lead to some confusing results such as <php>16 === 016</ | ||
This convention for octal integers is well established and followed by many programming languages (Java, C, C#, Golang, Haskell, and more). However, Python, JavaScript, and Rust [[https:// | This convention for octal integers is well established and followed by many programming languages (Java, C, C#, Golang, Haskell, and more). However, Python, JavaScript, and Rust [[https:// | ||
+ | |||
+ | Surprisingly PHP already has support for this notation when using the < | ||
+ | |||
+ | ===== Proposal ===== | ||
+ | |||
+ | Add support for the explicit octal notation '' | ||
+ | |||
+ | <code php> | ||
+ | 0o16 === 14; // true | ||
+ | 0o123 === 83; // true | ||
+ | |||
+ | 0O16 === 14; // true | ||
+ | 0O123 === 83; // true | ||
+ | |||
+ | 016 === 0o16; // true | ||
+ | 016 === 0O16; // true | ||
+ | </ | ||
===== Behaviour of numeric strings ===== | ===== Behaviour of numeric strings ===== | ||
- | As of PHP 7.0, hexadecimal numbers in strings are not considered numeric [[rfc: | + | |
+ | As of PHP 7.0, hexadecimal numbers in strings are not considered numeric [[rfc: | ||
< | < | ||
- | Therefore, support for strings | + | Numeric |
- | ===== Proposal ===== | + | This RFC has no impact on the behaviour of numeric strings. |
- | Add support for the explicit octal notation | + | |
===== Backward Incompatible Changes ===== | ===== Backward Incompatible Changes ===== | ||
Line 24: | Line 43: | ||
===== Proposed PHP Version(s) ===== | ===== Proposed PHP Version(s) ===== | ||
- | Next PHP 8.x. | + | PHP 8.1. |
===== RFC Impact ===== | ===== RFC Impact ===== | ||
==== To Existing Extensions ==== | ==== To Existing Extensions ==== | ||
Added support to the GMP extension. | Added support to the GMP extension. | ||
+ | |||
+ | Added support to the < | ||
==== To Opcache ==== | ==== To Opcache ==== | ||
Line 34: | Line 55: | ||
===== Unaffected PHP Functionality ===== | ===== Unaffected PHP Functionality ===== | ||
+ | |||
Implicit octal notation is unaffected. | Implicit octal notation is unaffected. | ||
===== Future Scope ===== | ===== Future Scope ===== | ||
+ | |||
* Deprecate the implicit octal notation. | * Deprecate the implicit octal notation. | ||
* Support hexadecimal, | * Support hexadecimal, | ||
+ | * Add a flag for the < | ||
+ | |||
+ | ===== Voting Choices ===== | ||
- | ===== Proposed Voting Choices ===== | ||
Per the Voting RFC, there is a single Yes/No vote requiring a 2/3 majority for this proposal to be accepted. | Per the Voting RFC, there is a single Yes/No vote requiring a 2/3 majority for this proposal to be accepted. | ||
Line 49: | Line 74: | ||
===== Patches and Tests ===== | ===== Patches and Tests ===== | ||
+ | |||
GitHub patch: https:// | GitHub patch: https:// | ||
Line 54: | Line 80: | ||
===== Implementation ===== | ===== Implementation ===== | ||
- | After the project is implemented, | + | |
- | - the version(s) it was merged | + | Merged |
- | - a link to the git commit(s) | + | - Commit: https://git.php.net/? |
- a link to the PHP manual entry for the feature | - a link to the PHP manual entry for the feature | ||
- a link to the language specification section (if any) | - a link to the language specification section (if any) | ||
===== References ===== | ===== References ===== | ||
+ | |||
[[https:// | [[https:// | ||
[[https:// | [[https:// | ||
[[https:// | [[https:// | ||
- | [[rfc: | + | [[rfc: |
rfc/explicit_octal_notation.1603234475.txt.gz · Last modified: 2020/10/20 22:54 by girgias