On Mon, Feb 17, 2020 at 3:09 AM tyson andre <tysonandre...@hotmail.com> wrote:
> Hi internals, > > I've created a straw poll at > https://wiki.php.net/rfc/calls_in_constant_expressions_poll , to measure > interest in allowing calls in different types of constant expressions. > If there aren't any problems with the poll structure or rules preventing > creating a poll, I was going to add it to the rfc index page and move it to > voting. > > This poll was created to gather opinions on which of the below statement > types would be desirable to change, and in which ways, before rewriting > https://wiki.php.net/rfc/calls_in_constant_expressions . > It seems desirable to change some of these expression types (e.g. > parameter defaults, static properties, static variable defaults) in > different ways from others. > (e.g. forbidding static property declaration expression results from > containing objects seems like a completely unnecessary limitation from > trying to reuse the implementation, in retrospect). > This poll was created for feedback on whether changes to the following > places had support, and what types of changes there were interest in. > > - Initial values of static or instance properties. This poll only > addresses static properties. > - Parameter defaults of functions, methods, and closures. > - Class constant values. > - Global constant values. > - Static variable default values. > > I'd asked earlier about creating a poll in > https://externals.io/message/108430 , but didn't receive a response. > > Thanks, > - Tyson > Hey Tyson, I feel like the results of this poll aren't going to be particularly meaningful, because it gets too caught up in the details and loses track of the big picture. If you ask people whether they want to allow function test($param = some_call()) { } they're going to to tell you "no", because that seems pretty esoteric and most people likely do not see a use-case for it. If you ask the same people whether they want to write function test(Dep $optionalDep = new Dep()) { } instead of function test(Dep $optionalDep = null) { if ($optionalDep === null) { $optionalDep = new Dep(); } } a lot of them are probably going to tell you "yes" now. The question didn't really change (new Dep is just a different type of "function call"), but the perception changes a lot. This is also why I think the focus on plain function calls in particular is somewhat detrimental. This is one of the cases where going for a paradigm shift (constant expression -> any expression) is "simpler" than doing an incremental change (extending constant expressions to allow function calls, and all the subtleties that entails.) Regards, Nikita