Gregory Beaver wrote:
Lukas Kahwe Smith wrote:
On 13.08.2008, at 22:18, Stanislav Malyshev wrote:
Simply include a script from two locations with different namespaces
or one
with namespace and the otherone without.
I'm afraid you misunderstand how namespaces work. As I explained
numerous times, namespaces are file-local, and this when including
file, it does not matter a bit what was including context.
I think Marcus is talking about files that are included that do not
specify a namespace explicitly. In this situation the context does matter.
We do not know if the developer in question is aware that the context
would matter in this case. Actually like I said in a previous email it
would be nice to at least not throw a warning if the file that is
included specifies an explicit namespace (I assume that is possible?).
Maybe adding a new "include" is a solution. This way developers can say
explicitly what they want to do without having to suppress the warning.
Then again quickly some smartass developer is going to teach people that
these annoying warnings go away if you just use this new include
everywhere. Then again, I am not sure if I even have my head wrapped
around this entire namespace thing.
Hi,
Currently, if you include a file within a class method that contains
function definitions, they remain functions outside the class. If you
include a file that contains a class.
In short, only global cpde is executed in the scope, and there is no
precedent in PHP to redefine re-usable elements based on scope.
Why would namespaces be any different? This whole argument makes no
sense to me.
Well, it depends how you view the scope. If you include a file that
defines a variable from within a function or a method, that variable
becomes function-scoped, not global. In the case of a namespaced
function or method including a file containing functions or classes,
those classes become global. That has, of course, always been the case,
but we haven't had the concept of a namespace context before and we
haven't had anything that was file-scoped like this. So people might
extrapolate from the function-context case to this and assume the wrong
thing. That's what Marcus' patch it about.
I happen to disagree with him and I think we should just write really
good docs explaining how namespaces work and provide a lot of examples.
-Rasmus
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php