> 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.

I'd definitely agree. If I was writing the RFC for calls in constant 
expressions again,
I'd focus more on adding concrete examples of where function calls/other 
expressions would make code easier to understand,
rather than focusing on implementation details.
At the time of writing the RFC, I thought a major objection would be whether or 
not it was actually feasible to implement,
and many people would be familiar with use cases where function calls in 
expressions would have made code more straightforward.

> 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.

Good example, I hadn't thought of mentioning `new` as an example for the "as 
many expression types as possible".
That also lets functions clearly enforce arguments are non-null.

> 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.)

The point of https://wiki.php.net/rfc/calls_in_constant_expressions_poll was to 
measure interest in "any expression",
but did a poor job of mentioning arguments in favor of it or how it'd simplify 
common examples.
With better arguments and examples, though, I'm still not certain if it'd be a 
2/3 majority for any option.

A straw poll or RFC arguing *only* in favor of a paradigm shift with better 
arguments and examples
might see different results.

- Tyson
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to