On 25/08/2024 16:29, Bilge wrote:
You can write, `include(1 + 1);`, because `include()` accepts an expression. You will get: "Failed opening '2' for inclusion". Should we restrict that? No, because that's just how expressions work in any context where they're allowed.
I think a better comparison might be the "new in initializers" and "fetch property in const expressions" RFCs, which both forbid uses which would naturally be allowed by the grammar. The rationale in those cases was laid out in https://wiki.php.net/rfc/new_in_initializers#unsupported_positions and https://wiki.php.net/rfc/fetch_property_in_const_expressions#supporting_all_objects
To pull out a point that might be overlooked at the bottom of my longer response earlier:
> As the RFC points out, library authors already worry about the maintenance burden of named argument support, will they now also need to question whether someone is relying on "default + 1" having some specific effect?
By saying "default can be used in any expression, as complex as the caller can imagine", we're implicitly saying "if you add a default to your function signature, that is no information a user can pull *out* as part of your API".
Regards, -- Rowan Tommins [IMSoP]