rfc:explicit_octal_notation

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Next revisionBoth sides next revision
rfc:explicit_octal_notation [2020/10/21 02:00] – Small note about octdec which already supports this prefix girgiasrfc:explicit_octal_notation [2020/11/07 08:33] – Add explicit mention of upper case notation. girgias
Line 3: Line 3:
   * Date: 2020-10-20   * Date: 2020-10-20
   * Author: George Peter Banyard, <girgias@php.net>   * Author: George Peter Banyard, <girgias@php.net>
-  * Status: Draft+  * Status: Under Discussion
   * First Published at: https://wiki.php.net/rfc/explicit_octal_notation   * First Published at: https://wiki.php.net/rfc/explicit_octal_notation
  
Line 12: Line 12:
 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://docs.python.org/3/reference/lexical_analysis.html#integer-literals|[1]]][[https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Numbers_and_dates|[2]]][[https://doc.rust-lang.org/rust-by-example/primitives/literals.html|[3]]] only accept or support an explicit octal notation ''0o''. 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://docs.python.org/3/reference/lexical_analysis.html#integer-literals|[1]]][[https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Numbers_and_dates|[2]]][[https://doc.rust-lang.org/rust-by-example/primitives/literals.html|[3]]] only accept or support an explicit octal notation ''0o''.
  
-Surprisingly PHP already has support for this notation and ''0O'' when using the <php>octdec()</php> and <php>base_convert()</php> functions.+Surprisingly PHP already has support for this notation when using the <php>octdec()</php> and <php>base_convert()</php> functions.
  
 ===== Proposal ===== ===== Proposal =====
  
-Add support for the explicit octal notation ''0o'' for integer literals analogous to ''0x'' and ''0b'' for hexadecimal and binary.+Add support for the explicit octal notation ''0o''/''0O'' for integer literals analogous to ''0x''/''0X'' and ''0b''/''0B'' for hexadecimal and binary.
  
 <code php> <code php>
 0o16 === 14; // true 0o16 === 14; // true
 0o123 === 83; // true 0o123 === 83; // true
 +
 +0O16 === 14; // true
 +0O123 === 83; // true
  
 016 === 0o16; // true 016 === 0o16; // true
 +016 === 0O16; // true
 </code> </code>
  
rfc/explicit_octal_notation.txt · Last modified: 2021/01/04 20:12 by girgias