Re: [PHP-DEV] Simple Namespace Proposal
by Giedrius D other posts by this author
Jul 16 2007 12:03AM messages near this date
Re: [PHP-DEV] Simple Namespace Proposal
|
Re: [PHP-DEV] Simple Namespace Proposal
On 7/16/07, Stanislav Malyshev <stas@[...].com> wrote:
> > The other thing that bothers me is namespaces nesting. It was said
> > that namespaces
> > nesting is not supported. Then I'm missing a point in having namespace
> > named "A::B".
>
> The same reason some people write $a = f($z, $t) and some write
> $parsed_template = template_parser($template, $data_values) :)
>
I wasn't talking about a short/long names :-)
I was talking about a separator inside a namespace name.
> > Lets say I have three files:
> >
> > a.php:
> > <?php
> > namespace A;
> >
> > function foo()
> > {
> > }
> > ?>
> >
> > b.php:
> > <?php
> > namespace A::B;
> >
> > function bar()
> > {
> > //foo();
> > }
> > ?>
> >
> > index.php:
> > <?php
> > require 'a.php';
> > require 'b.php';
> >
> > import A;
> > foo(); // should call A::foo(), right?
> > B::bar(); // will this call A::B::bar()?
> > ?>
>
> import A is a no-op. You do import A::B and then you can do B::bar.
> import N means "something that is named N can now be referred only by
> it's 'last name' last(N), last name being last segment of the long
> name". If you have short names, you don't need namespaces, but if you
> have names like PEAR::DB::Record::Type::Modifier::Exception, you
> probably do :)
>
> > Now if this does not work then whats the point in having namespace
> > "A::B" instead of "A_B"? IMHO this brings more confusion then
> > clearness.
>
> The point is you can a) omit namespace prefix inside namespace and b)
> use just B (or C if you wish) instead of A::B outside, once you did
> import. As I said, with long names it makes sense, with short ones you
> are OK without it.
a) I was talking about namespace name "A_B" not class/function name.
b) So as far as I understand "import" doesn't actually *import* names
from specified
namespace to the current one but just renames long namespace name to a
shorter one. And if I get it right the separator in the namespace name
is allowed
and required only to express default name when importing without "as".
Am I right?
Regards,
Giedrius
--
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
|