Re: [RFC] Add Directive to Make All Namespaced Function Calls Global

From: Date: Sun, 04 Aug 2024 18:31:51 +0000
Subject: Re: [RFC] Add Directive to Make All Namespaced Function Calls Global
References: 1 2  Groups: php.internals 
Request: Send a blank email to internals+get-124749@lists.php.net to get a copy of this message
> > > > “Should there be some way for developers to signal to the parser at > > compile time that all unqualified function names found in a > > namespace > > context are global, without a namespace lookup?” > > > > Yes: We should do this, let's discuss syntax possibilities. > > > > No: This should not be a feature at all. > > > > Thank you for your consideration. > > Hi Nick > > I'm not sure how I feel about adding an additional signaling / syntax > system > to signal the parser to change the behaviour of function lookup. > It means people have to take into account that a fundamental > behaviour can be changed. > PHP is already hard to use IMHO because of many things you have to > keep into the > back of your head, and adding something like this adds even more > complexity. > If we're going to make such a change I'd rather have it > unconfigurable. > > Kind regards > Niels My thought was that it would have some clean and simple syntax, like: namespace foo using global functions; class MyClass{ } When the parser hits that token, it just sets a flag and acts like every unqualified classname has a backslash in front of it. For everyone else: namespace foo; class MyClass{ } ...would still work exactly the same as it does now. And would keep BC.

« previous php.internals (#124749) next »