Re: [PHP-DEV] Simple Namespace Proposal
by Stefan Priebsch other posts by this author
Jul 4 2007 7:54AM messages near this date
Re: [PHP-DEV] Simple Namespace Proposal
|
Re: [PHP-DEV] Simple Namespace Proposal
Hi Dmitry,
it would be great to have namespaces in PHP6, as these always
longer-getting classnames are somewhat annoying.
I don't want to start a discussion about the separator (I think there
was one before), but:
> > 6) Calls to qualified functions are resolved at run-time. Call to
> > "A::B::foo()" first tries to call function foo() from namespace
"A::B", then
> > it tries to find class "A::B (__autoload() it if necessary) and call its
> > static function foo()
If I am not mislead this ambiguity is due to the fact that :: is the
namespace separator? If, so I'd rather suggest changing the separator,
because one could alter the program's behaviour by adding a function
foo() to a namespace thus making PHP call this function instead of the
method. Besides, a lot of less experiences programmers would not be sure
when which function/method is actually called.
> > All class and function names inside are automatically prefixed with
> > namespace name. Inside namespace, local name always takes precedence
over
> > global name. It is possible to use the same namespace in several PHP
files.
> > The namespace declaration statement must be the very first statement in
> > file.
I take it that when I include or conditionally include, the included
file has its own namespace, if one is declared in that file. What if I
do not declare a namespace in an include file? Does this file "inherit"
the current namespace or are the contents added to the global namespace?
> > point of definition down to the end of file. It is recommended
however to
> > place imports at the beginning of the file. Import statements have
effect
> > only on file where they are written.
Could this result in name conflicts when including files that have their
own import statements?
> > 4) calls to unqualified functions that are not defined in current
namespace
> > are resolved in run-time. The call to function foo() inside namespace
(A::B)
> > first tries to find and call function from current namespace
A::B::foo() and
> > if it doesn't exist PHP tries to call internal function foo(). Note that
> > using foo() in namespace you can call only internal PHP functions,
however
> > using ::foo() you are able to call any function from global namespace.
Does this mean that a programmer could "override" an internal PHP
function, possibly accidentally?
Kind regards,
Stefan
--
> e-novative> - We make IT work for you.
e-novative GmbH - HR: Amtsgericht München HRB 139407
Sitz: Wolfratshausen - GF: Dipl. Inform. Stefan Priebsch
http://www.e-novative.de
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php
Thread:
Dmitry Stogov
Derick Rethans
Dmitry Stogov
Dmitry Stogov
dz
David Coallier
Guilherme Blanco
Stanislav Malyshev
Dmitry Stogov
Markus Fischer
Stanislav Malyshev
Stanislav Malyshev
Stanislav Malyshev
Giedrius D
Stanislav Malyshev
Giedrius D
Stanislav Malyshev
Giedrius D
Andrew Minerd
Stanislav Malyshev
David Coallier
Chris#
Dmitry Stogov
nicobn
Chris#
Chrish
Dmitry Stogov
Andrei Zmievski
Stefan Priebsch
Stanislav Malyshev
Richard Lynch
Dmitry Stogov
Stanislav Malyshev
Andrei Zmievski
Stefan Priebsch
Stanislav Malyshev
Stefan Priebsch
Richard Lynch
Stefan Priebsch
Jani Taskinen
David Coallier
Robert Cummings
Richard Lynch
Stanislav Malyshev
Lukas Kahwe Smith
Derick Rethans
Stefan Priebsch
Stanislav Malyshev
Derick Rethans
Stanislav Malyshev
Stanislav Malyshev
Stanislav Malyshev
Dmitry Stogov
Stefan Priebsch
Dmitry Stogov
Jeremy Privett
Stanislav Malyshev
nicobn
Tony Bibbs
Stanislav Malyshev
Stefan Priebsch
David Coallier
Rich Buggy
Stanislav Malyshev
Stefan Priebsch
David Coallier
Dmitry Stogov
Andrei Zmievski
Hans Lellelid
dz
Guilherme Blanco
Alexey Zakhlestin
Stanislav Malyshev
Jeremy Privett
Dmitry Stogov
Arpad Ray
Dmitry Stogov
Stanislav Malyshev
Markus Fischer
David Coallier
Stanislav Malyshev
Brian Moon
Dmitry Stogov
Stanislav Malyshev
Brian Moon
Stanislav Malyshev
Dmitry Stogov
Stefan Walk
Dmitry Stogov
David Coallier
Dmitry Stogov
Stefan Priebsch
Stanislav Malyshev
Stefan Priebsch
Larry Garfield
Dmitry Stogov
Larry Garfield
Dmitry Stogov
Derick Rethans
Dmitry Stogov
nicobn
Sebastian Bergmann
Dmitry Stogov
nicobn
Rasmus Lerdorf
Lucas Nealan
Stefan Priebsch
Rasmus Lerdorf
Stefan Priebsch
Sebastian Bergmann
Stefan Priebsch
Dmitry Stogov
Sebastian Bergmann
Stanislav Malyshev
davidc
Stanislav Malyshev
|