rfc:explicit_octal_notation
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revisionNext revisionBoth sides next revision | ||
rfc:explicit_octal_notation [2020/10/20 22:32] – created girgias | rfc:explicit_octal_notation [2020/11/11 12:34] – made version explicit. danack | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== PHP RFC: Explicit octal integer literal notation ====== | ====== PHP RFC: Explicit octal integer literal notation ====== | ||
- | * Version: | + | * Version: |
* 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 ===== | ===== Proposal ===== | ||
- | Add support for the explicit octal notation '' | + | |
+ | 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 ===== | ||
+ | |||
+ | As of PHP 7.0, hexadecimal numbers in strings are not considered numeric [[rfc: | ||
+ | |||
+ | < | ||
+ | |||
+ | Numeric strings in PHP are //always// decimal. Analogous to the example from the introduction < | ||
+ | |||
+ | This RFC has no impact on the behaviour of numeric strings. | ||
===== Backward Incompatible Changes ===== | ===== Backward Incompatible Changes ===== | ||
Line 18: | 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 28: | 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, | ||
+ | * Add a flag for the < | ||
===== Proposed Voting Choices ===== | ===== Proposed Voting Choices ===== | ||
- | Include these so readers know where you are heading and can discuss | + | |
+ | Per the Voting RFC, there is a single Yes/No vote requiring a 2/3 majority for this proposal to be accepted. | ||
+ | |||
+ | <doodle title=" | ||
+ | * Yes | ||
+ | * No | ||
+ | </ | ||
===== Patches and Tests ===== | ===== Patches and Tests ===== | ||
+ | |||
GitHub patch: https:// | GitHub patch: https:// | ||
Line 42: | Line 80: | ||
===== Implementation ===== | ===== Implementation ===== | ||
+ | |||
After the project is implemented, | After the project is implemented, | ||
- the version(s) it was merged into | - the version(s) it was merged into | ||
Line 49: | Line 88: | ||
===== References ===== | ===== References ===== | ||
+ | |||
[[https:// | [[https:// | ||
[[https:// | [[https:// | ||
- | [[https:// | + | [[https:// |
+ | [[rfc: | ||
rfc/explicit_octal_notation.txt · Last modified: 2021/01/04 20:12 by girgias