On Tue, Jan 28, 2020 at 9:22 PM tyson andre <tysonandre...@hotmail.com> wrote:
> > I've opened the vote on https://wiki.php.net/rfc/use_global_elements > after weighing the pros and cons of discussed alternative approaches. > Yesterday, I've finished the last set of updates I announced I would do > based on RFC feedback. > > (that update was to require the statement 'use function ...'/'use const > ...' before declaring that function/const > outside the global namespace, > if declare(function_and_const_lookup='global') is opted into) > > Voting closes on 2020-02-11. > Notwithstanding the excellent work done in the PR, I lean toward a No vote. Suppose I'm presented with this diff (and only this diff): $a = array_diff($x, $y); + if (count($a)) die('Unexpected differences'); Where does count come from? I can't tell from this diff. It could be local to this namespace, or it could be global. In the current implementation, I have to scroll to the top of the file, check for what namespace I am in, and what use are made. In the proposed implementation, I have also to check the top of the file, but now its for "declare(function_and_cost_lookup='global')" and the presence (or not) of "use function count". It's not clear to me this is an improvement over status quo. Indeed, I worry that implementing the proposal may increase overall cognitive burden for PHP developers. Today, any developer can look at any file or snippet in any code base, anywhere in the world, and know that using an unqualified name follows a single, language-defined algorithm. Were this proposal accepted, developers no longer have that guarantee. The code might be using the original algorithm, or it might be using the new algorithm. The only way to know is to check for and remember the state based on the presence of -- and value of -- this new declaration. Resolving ambiguities has a compute cost and a cognitive cost. While the proposal improves the compute cost, I'm not sure the same can be said of the cognitive cost. So I am leaning toward a No vote. What do you think?