On Wednesday 13 August 2008 6:00:21 pm Lukas Kahwe Smith wrote:

> >> 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.
>
> My previous comments were wrong. Sorry about causing confusion. As
> Rasmus points out what Marcus is trying to solve with the warning is
> the false expectation that something that is included in a namespace
> would also be namespaced. This is not the case. As such if you want
> the included code to be in some namespace you have to explicitly do so
> in the file that is being included.
>
> As such I also agree that we do not need a warning. It will do at
> least as much harm to legitimate uses as it tries to solve for
> illegitimate uses. And those problematic users will hopefully decide
> to read out docs ..
>
> regards,
> Lukas Kahwe Smith
> [EMAIL PROTECTED]

From a developer perspective, I do not expect the code's namespace to be 
dependent on how it's included either.  Especially with the non-braces syntax 
implemented currently, and the way includes of files with function/class 
definitions work now, I expect them to be globally defined, which is what 
happens.  

I would also note that "include up front and have a good autoload scheme" 
works great if you are writing all classes.  If you're trying to use 
namespaces and functions, there is no autoload.  That makes the autoload 
argument moot, and pre-loading everything up front can get ridiculously 
expensive in large systems, and even then you don't always know what to load 
up front.  (Think anything that accepts plugins.)  So an answer of "well if 
it throws a warning when you do that, don't do that" is simply not realistic 
in practice.  

-- 
Larry Garfield
[EMAIL PROTECTED]

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

Reply via email to