rfc:pow-operator

Differences

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

Link to this comparison view

Both sides previous revisionPrevious revision
Next revisionBoth sides next revision
rfc:pow-operator [2013/12/19 19:20] datibbawrfc:pow-operator [2013/12/21 05:45] datibbaw
Line 4: Line 4:
   * Date: 2013-11-23   * Date: 2013-11-23
   * Author: Tjerk Meesters, datibbaw@php.net   * Author: Tjerk Meesters, datibbaw@php.net
-  * Status: Voting+  * Status: Under Discussion
   * First Published at: http://wiki.php.net/rfc/pow-operator   * First Published at: http://wiki.php.net/rfc/pow-operator
   * Revision (0.1 → 0.2): 2013-12-19   * Revision (0.1 → 0.2): 2013-12-19
Line 10: Line 10:
 ===== Introduction ===== ===== Introduction =====
  
-This proposal is three-fold:+This proposal is two-fold:
  
-  - Turn the existing [[http://php.net/pow|pow()]] function into a language construct.+  - Introduce an exponential (right associativeoperator ''<nowiki>**</nowiki>''.
     * Avoids a function call.     * Avoids a function call.
     * Support for [[rfc:operator_overloading_gmp|GMP overloading]].     * Support for [[rfc:operator_overloading_gmp|GMP overloading]].
-  - Introduce an exponential (right associative) operator ''<nowiki>**</nowiki>''. 
     * Easier to read and shorter to write.     * Easier to read and shorter to write.
     * Can be found in other languages.     * Can be found in other languages.
Line 21: Line 20:
  
 ===== Proposal ===== ===== Proposal =====
- 
-**pow() as language construct** 
- 
-No changes to existing code, safe for one: 
- 
-<code php> 
-var_dump(pow([], 2)); // int(0) instead of float(0) 
-</code> 
- 
-Using ''pow()'' as a callback will still work as expected: 
- 
-<code php> 
-call_user_func('pow', 2, 3); // 8 
-</code> 
- 
-**Power operator** 
  
 A short working example: A short working example:
Line 82: Line 65:
 echo ~3 ** 2; // -10 (not 16) echo ~3 ** 2; // -10 (not 16)
 </code> </code>
 +
 +===== Changelog =====
 +
 +21-Dec-2013: Reverted the change that turns pow() into a language construct due to BC breaks.
 +21-Dec-2013: Closed vote and moved RFC back to Discussion status
  
 ===== Discussion ===== ===== Discussion =====
Line 173: Line 161:
 ===== Open Issues ===== ===== Open Issues =====
  
-None.+An issue was brought up that due to pow() itself becoming a language construct, it would break existing code that uses "public function pow()".
  
 ===== Vote ===== ===== Vote =====
Line 191: Line 179:
 ---- ----
  
-<doodle title="Should PHP get a power operator in 5.6?" auth="datibbaw" voteType="single" closed="false">+<doodle title="Should PHP get a power operator in 5.6?" auth="datibbaw" voteType="single" closed="true">
    * Yes, right associative    * Yes, right associative
    * Yes, non associative    * Yes, non associative
rfc/pow-operator.txt · Last modified: 2017/09/22 13:28 by 127.0.0.1