On Wed, Feb 7, 2018 at 7:02 AM, Rowan Collins <rowan.coll...@gmail.com> wrote:
> On 3 February 2018 08:27:18 GMT+00:00, Wes <netmo....@gmail.com> wrote:
>>Hello PHPeople. I just published the RFC "Deprecation of fallback to
>>root
>>scope".
>>
>>https://wiki.php.net/rfc/fallback-to-root-scope-deprecation
>
>
> Given the discussion so far, how about taking the "opposite" approach:
> deprecate unprefixed reference to functions which *are* in the current
> namespace.
>
> Proposal:
> - PHP 7.3: Add syntax to explicitly reference functions and constants in
> the current namespace, such as .\foo or this\foo
> - PHP 7.4: Raise E_DEPRECATED whenever an unprefixed function/constant
> resolves to something in the current namespace (other than via "use" alias)
> - PHP 8.0: Make all unprefixed functions/constants always refer to the root
> namespace
>
> Pros:
> - Much less disruptive change, as the majority of unprefixed function calls
> are to global functions, and would not need to change.
> - Both cases can be made unambiguous if the author wants to.
> - Apparently OpCache currently mitigates the performance hit by caching
> lookups in a technically unclean way. Users hit by this can make their code
> unambiguous in 7.3, and the optimisation will become clean in 8.0.
> - Function / constant autoloading can be added in 7.x if we accept the
> caveat that unprefixed functions will not be autoloaded; or in 8.0 if we
> want to cover everything.
>
> Cons:
> - Slightly uglier syntax.
> - Still a breaking change (in 8.0).
> - Class names will still be resolved differently from function and constant
> names.
> - Code actively using the fallback system (e.g. tests masking global
> functions with mocks) will need refactoring as there is no way to opt into
> the old behaviour.
> - The .\foo() syntax may appear in similar places to the . concatenation
> operator. Even if technically unambiguous and implementable in the parser,
> this may be confusing to users. A keyword approach like this\foo() would be
> clearer, but more verbose.
>
> What do people think? Is it worth expanding this out into an alternative
> RFC?
>
> Regards,
> --
> Rowan Collins [IMSoP]

My opinion is that the result is both uglier and *even less
consistent* with namespaced types. I'm glad you are at least thinking
about alternative proposals but this is worse than both the original
proposal and doing nothing.

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

Reply via email to