Re: namespace separator and whining

From: Date: Tue, 04 Nov 2008 16:44:50 +0000
Subject: Re: namespace separator and whining
References: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16  Groups: php.internals 
Request: Send a blank email to internals+get-41645@lists.php.net to get a copy of this message
Hi Greg, all,
For this reason, the only resolution that we should be considering is: classes: 1) try ns::class 2) autoload ns::class 3) fail functions/constants: 1) try ns::function/ns::const 2) try internal function/const 3) fail.
I see this as giving priority to library authors rather than the average PHP user. So here's another option - and if I mention the word INI, will y'all promise to read to the end before you shout at me? We could have an INI_SYSTEM switch. ns.lookup=Off means you _have_ to prefix because otherwise resolution will fail with a fatal error, but ns.lookup=On means that anything not prefixed and not local goes through the full lookup, i.e. it does what is currently done outside a namespace context. You'd switch ns.lookup off during development and on in production, and the default would be on. Prefixed elements would be found at the first try regardless of the setting, but would fail after a single check for a global value if the element is not found when the setting's off. Non-prefixed code would fail when the setting's off, but would otherwise get by except in cases of ambiguity (easily remedied with a '\'). It would, however, run slower and be more prone to conflict, particularly in complex sites or applications. We make it very, very clear in the docs that prefixing is best practice, but at the same time we allow John Doe to import a couple of namespaced libraries without putting him through prefix hell. What am I missing? - Steph

« previous php.internals (#41645) next »