rfc:calls_in_constant_expressions_poll

Differences

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

Link to this comparison view

Next revision
Previous revision
rfc:calls_in_constant_expressions_poll [2020/02/17 01:46] – created tandrerfc:calls_in_constant_expressions_poll [2020/03/04 13:53] (current) – Close the poll tandre
Line 1: Line 1:
 ====== Poll: Places to allow function calls in constant expressions ====== ====== Poll: Places to allow function calls in constant expressions ======
-  * Version: 0.1 +  * Version: 0.2 
-  * Date: 2020-02-16 (use today's date here)+  * Date: 2020-02-16
   * Author: Tyson Andre, tandre@php.net   * Author: Tyson Andre, tandre@php.net
-  * Status: Draft+  * Status: Closed (ends 2020-03-04)
   * First Published at: https://wiki.php.net/rfc/calls_in_constant_expressions_poll   * First Published at: https://wiki.php.net/rfc/calls_in_constant_expressions_poll
  
Line 16: Line 16:
   - Static variable default values.   - Static variable default values.
  
-This poll was created to gather opinions on which of the above statement types would be desirable to change, and in which ways.+This poll was created to gather opinions on which of the above statement types would be desirable to change, and in which ways, to shape subsequent RFCs. It seems desirable to change some of these expression types (e.g. parameter defaults, static properties) in different ways from others.
  
 ===== Proposal ===== ===== Proposal =====
Line 23: Line 23:
 It was later changed to support only a whitelist of function calls. It was later changed to support only a whitelist of function calls.
  
-Because of the following list of reasons, that RFC is being put on hold to gather feedback before continuing work on the implementation.+Because of the following list of reasons, that RFC is being put on hold to gather feedback before rewriting it.
  
-  * That RFC would affect those 5 use cases the same way. Although the check for constant expressions is currently the same for those 5 use cases, there's no reason to force it to continue to be the same in the future.+  * That RFC would affect those 5 use cases the same way. Although the restriction to constant expressions is currently the same for those 5 use cases, there's no technical reason to force them to continue to be the same in the future.
   * It would be useful to allow any function calls (even those returning objects or references) in parameter defaults and static property defaults (e.g. methods, functions returning objects, .). (Parameter defaults containing function calls would behave as if they were evaluated every time the function was called without that parameter)   * It would be useful to allow any function calls (even those returning objects or references) in parameter defaults and static property defaults (e.g. methods, functions returning objects, .). (Parameter defaults containing function calls would behave as if they were evaluated every time the function was called without that parameter)
   * Preferring to make a choice on whether or not the RFC uses a whitelist before the vote is started.   * Preferring to make a choice on whether or not the RFC uses a whitelist before the vote is started.
Line 39: Line 39:
 The planned ''strict_types'' behavior is to use the ''strict_types'' setting of the file containing the constant expression. The planned ''strict_types'' behavior is to use the ''strict_types'' setting of the file containing the constant expression.
  
-===== Proposed Voting Choices =====+===== Vote =====
  
 The evaluation order and error handling would be as described in https://wiki.php.net/rfc/calls_in_constant_expressions , except where noted otherwise. The evaluation order and error handling would be as described in https://wiki.php.net/rfc/calls_in_constant_expressions , except where noted otherwise.
Line 46: Line 46:
 (e.g. ''const X = ["constant value", any_function_call()][0]'' will not throw an error about being an invalid constant even if ''any_function_call()'' contains objects or references, because the final result is the string ''"constant value"'') (e.g. ''const X = ["constant value", any_function_call()][0]'' will not throw an error about being an invalid constant even if ''any_function_call()'' contains objects or references, because the final result is the string ''"constant value"'')
  
 +Voting ends March 4th, 2020.
  
- +<doodle title="Support calls in class constants" auth="tandre" voteType="single" closed="true">
-<doodle title="Support calls in class constants" auth="tandre" voteType="single" closed="false">+
    * No    * No
    * Whitelist of global functions    * Whitelist of global functions
Line 54: Line 54:
 </doodle> </doodle>
 . .
-<doodle title="Support calls in global constants" auth="tandre" voteType="single" closed="false">+<doodle title="Support calls in global constants" auth="tandre" voteType="single" closed="true">
    * No    * No
    * Whitelist of global functions    * Whitelist of global functions
Line 66: Line 66:
   * ''function($x) { return $x*$x; }''   * ''function($x) { return $x*$x; }''
  
-<doodle title="Support calls in static property declarations" auth="tandre" voteType="single" closed="false">+<doodle title="Support calls in static property declarations" auth="tandre" voteType="single" closed="true">
    * No    * No
    * Whitelist of global functions    * Whitelist of global functions
Line 73: Line 73:
 </doodle> </doodle>
 . .
-<doodle title="Support calls in static variables" auth="tandre" voteType="single" closed="false">+<doodle title="Support calls in static variables" auth="tandre" voteType="single" closed="true">
    * No    * No
    * Whitelist of global functions    * Whitelist of global functions
Line 82: Line 82:
 . .
  
-<doodle title="Support calls in parameter defaults" auth="tandre" voteType="single" closed="false">+<doodle title="Support calls in parameter defaults" auth="tandre" voteType="single" closed="true">
    * No    * No
    * Whitelist of global functions    * Whitelist of global functions
Line 91: Line 91:
 ===== References ===== ===== References =====
 https://wiki.php.net/rfc/calls_in_constant_expressions https://wiki.php.net/rfc/calls_in_constant_expressions
 +
 +https://externals.io/message/108630
  
 ===== Rejected Features ===== ===== Rejected Features =====
  
 Changing the behavior of instance properties was rejected. If functions were only invoked once, then ''private $x = generate_unique_id()'' would be unintuitive. If it was invoked for every created object, the implementation would require changes to internals that I'm probably unable to implement (these changes would affect unserialization, ways when object creation can throw, the behavior of internal functions that create and return objects, opcache, etc.) Changing the behavior of instance properties was rejected. If functions were only invoked once, then ''private $x = generate_unique_id()'' would be unintuitive. If it was invoked for every created object, the implementation would require changes to internals that I'm probably unable to implement (these changes would affect unserialization, ways when object creation can throw, the behavior of internal functions that create and return objects, opcache, etc.)
rfc/calls_in_constant_expressions_poll.1581903966.txt.gz · Last modified: 2020/02/17 01:46 by tandre