# Alternative to multiple namespaces per file

- Thread: https://externals.io/message/38019
- Original archive: https://news-web.php.net/php.internals/38019
- Started by Stan Vassilev | FM on 2008-05-31T12:10:35+00:00
- Messages: 10
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #38019 — Stan Vassilev | FM — 2008-05-31T12:10:35+00:00

URL: https://externals.io/message/38019#38019

Hi,

I suppose this has been discussed before, so I'll not repeat reasons unless requested, but I just want to offer a possible feature to mitigate the impact of "one namespace per file", which doesn't have controversial syntax and hopefully less difficulties in the implementation:

class Fully::Qualified::Class::Name::Declaration { .... }

same as:

namespace Fully::Qualified::Class::Name;

class Declaration { .... }

... except of course this allows classes of different namespaces to be declared in one file. Most namespace-enabled languages consider the above declarations equivalent. Share your opinions.

Regards, 
Stan Vassilev

---

## #38021 — James Dempster — 2008-05-31T12:43:00+00:00

URL: https://externals.io/message/38019#38021 · In reply to: #38019

what I find really annoying about all this namespace stuff, is how would
that be any different from

class Fully_Qualified_Class_Name_Declaration { }

/James

On Sat, May 31, 2008 at 1:10 PM, Stan Vassilev | FM <sv_forums@fmethod.com>
wrote:

>
> Hi,
>
> I suppose this has been discussed before, so I'll not repeat reasons unless
> requested, but I just want to offer a possible feature to mitigate the
> impact of "one namespace per file", which doesn't have controversial syntax
> and hopefully less difficulties in the implementation:
>
> class Fully::Qualified::Class::Name::Declaration { .... }
>
> same as:
>
> namespace Fully::Qualified::Class::Name;
>
> class Declaration { .... }
>
> ... except of course this allows classes of different namespaces to be
> declared in one file. Most namespace-enabled languages consider the above
> declarations equivalent. Share your opinions.
>
> Regards,
> Stan Vassilev

---

## #38022 — Stan Vassilev | FM — 2008-05-31T12:51:25+00:00

URL: https://externals.io/message/38019#38022 · In reply to: #38021

Hi,

The community wanted namespaces. This is not exactly the namespaces it wanted, but since they're going in, I think the best course of action is to solve the big obvious problems so they are at least usable and extendable in future versions of PHP.

If you have to ask *me* personally, I'd not put namespaces in 5.3 and have a big discussion about the entire implementation. But alas.

I think those "showstopper" problems with namespaces are:

1) one namespace per file (look at frameworks like Symphony which compile their classes together for performance, they will never be able to switch to, or support namespaces).

2) silent collisions between namespaced function and static method in a class with the same name (no errors or anything).

3) different resolution rules for userspace and internal functions.

4) subtly different resolution rules for functions/classes/constants

So I'm trying to to address 1) in this thread.

Regards, 
Stan Vassilev 
  ----- Original Message ----- 
  From: James Dempster 
  To: Stan Vassilev | FM 
  Cc: internals@lists.php.net 
  Sent: Saturday, May 31, 2008 3:43 PM
  Subject: Re: [PHP-DEV] Alternative to multiple namespaces per file


  what I find really annoying about all this namespace stuff, is how would that be any different from

  class Fully_Qualified_Class_Name_Declaration { }

  /James


  


    Hi,

    I suppose this has been discussed before, so I'll not repeat reasons unless requested, but I just want to offer a possible feature to mitigate the impact of "one namespace per file", which doesn't have controversial syntax and hopefully less difficulties in the implementation:

    class Fully::Qualified::Class::Name::Declaration { .... }

    same as:

    namespace Fully::Qualified::Class::Name;

    class Declaration { .... }

    ... except of course this allows classes of different namespaces to be declared in one file. Most namespace-enabled languages consider the above declarations equivalent. Share your opinions.

    Regards,
    Stan Vassilev

---

## #38023 — James Dempster — 2008-05-31T13:02:20+00:00

URL: https://externals.io/message/38019#38023 · In reply to: #38022

I would agree with you, I think namespaces should wait for a later version.
Maybe 6 or even later. I believe there are many problems that need to be
sorted be namespaces hit release.

Maybe we could do something like so.

namespace Fully::Qualified::Class::Name class Declaration extends Whatever
implents MyInterface { }

I have reservations in using :: as a resolution operator which can easily
clash with normal class space usage.

Is it too late to have these discussions?? It seems I missed the big
namespace discussions on the mailing list and things have already gone
ahead.

/James

On Sat, May 31, 2008 at 1:51 PM, Stan Vassilev | FM <sv_forums@fmethod.com>
wrote:

>  Hi,
>
> The community wanted namespaces. This is not exactly the namespaces it
> wanted, but since they're going in, I think the best course of action is to
> solve the big obvious problems so they are at least usable and extendable in
> future versions of PHP.
>
> If you have to ask *me* personally, I'd not put namespaces in 5.3 and have
> a big discussion about the entire implementation. But alas.
>
> I think those "showstopper" problems with namespaces are:
>
> 1) one namespace per file (look at frameworks like Symphony which compile
> their classes together for performance, they will never be able to switch
> to, or support namespaces).
>
> 2) silent collisions between namespaced function and static method in a
> class with the same name (no errors or anything).
>
> 3) different resolution rules for userspace and internal functions.
>
> 4) subtly different resolution rules for functions/classes/constants
>
> So I'm trying to to address 1) in this thread.
>
> Regards,
> Stan Vassilev
>
> ----- Original Message -----
> *From:* James Dempster <letssurf@gmail.com>
> *To:* Stan Vassilev | FM <sv_forums@fmethod.com>
> *Cc:* internals@lists.php.net
> *Sent:* Saturday, May 31, 2008 3:43 PM
> *Subject:* Re: [PHP-DEV] Alternative to multiple namespaces per file
>
> what I find really annoying about all this namespace stuff, is how would
> that be any different from
>
> class Fully_Qualified_Class_Name_Declaration { }
>
> /James
>
> On Sat, May 31, 2008 at 1:10 PM, Stan Vassilev | FM <sv_forums@fmethod.com>
> wrote:
>
> > […]

---

## #38024 — Alain Williams — 2008-05-31T13:05:08+00:00

URL: https://externals.io/message/38019#38024 · In reply to: #38022

> Hi,
> 
> The community wanted namespaces. This is not exactly the namespaces it wanted, but since they're going in, I think the best course of action is to solve the big obvious problems so they are at least usable and extendable in future versions of PHP.
> 
> If you have to ask *me* personally, I'd not put namespaces in 5.3 and have a big discussion about the entire implementation. But alas.
> 
> I think those "showstopper" problems with namespaces are:
> 
> 1) one namespace per file (look at frameworks like Symphony which compile their classes together for performance, they will never be able to switch to, or support namespaces).
> ...

To which I would add: namespaces are not for variables, this I would like to see.

-- 
Alain Williams
Linux Consultant - Mail systems, Web sites, Networking, Programmer, IT Lecturer.
+44 (0) 787 668 0256  http://www.phcomp.co.uk/
Parliament Hill Computers Ltd. Registration Information: http://www.phcomp.co.uk/contact.php
Chairman of UKUUG: http://www.ukuug.org/
#include <std_disclaimer.h

---

## #38025 — Stan Vassilev | FM — 2008-05-31T13:08:14+00:00

URL: https://externals.io/message/38019#38025 · In reply to: #38023

Hi,

Your suggestion seems ok too, anything is better than *no functioning way at all to do it*.

Regards, 
Stan Vassilev 
  ----- Original Message ----- 
  From: James Dempster 
  To: Stan Vassilev | FM 
  Cc: internals@lists.php.net 
  Sent: Saturday, May 31, 2008 4:02 PM
  Subject: Re: [PHP-DEV] Alternative to multiple namespaces per file


  I would agree with you, I think namespaces should wait for a later version. Maybe 6 or even later. I believe there are many problems that need to be sorted be namespaces hit release.

  Maybe we could do something like so.

  namespace Fully::Qualified::Class::Name class Declaration extends Whatever implents MyInterface { }

  I have reservations in using :: as a resolution operator which can easily clash with normal class space usage.

  Is it too late to have these discussions?? It seems I missed the big namespace discussions on the mailing list and things have already gone ahead.

---

## #38034 — Larry Garfield — 2008-05-31T17:01:08+00:00

URL: https://externals.io/message/38019#38034 · In reply to: #38023

> I would agree with you, I think namespaces should wait for a later version.
> Maybe 6 or even later. I believe there are many problems that need to be
> sorted be namespaces hit release.
>
> Maybe we could do something like so.
>
> namespace Fully::Qualified::Class::Name class Declaration extends Whatever
> implents MyInterface { }
>
> I have reservations in using :: as a resolution operator which can easily
> clash with normal class space usage.
>
> Is it too late to have these discussions?? It seems I missed the big
> namespace discussions on the mailing list and things have already gone
> ahead.
>
> /James

Unfortunately it probably is.  I recall someone did raise the 
ClassName::staticMethod() vs. Namespace::function() collision problem months 
ago, and the response at the time was "Pfft, like who uses classes and 
functions in the same project, anyway?"  

(Of course, the answer is "well I do" but I've long since learned that such 
answers don't carry much weight around here, so I mostly just read to see 
where the language is going rather than to influence it.  So I've just 
resigned myself to not being able to use namespaces in PHP.)

-- 
Larry Garfield			AIM: LOLG42
larry@garfieldtech.com		ICQ: 6817012

"If nature has made any one thing less susceptible than all others of 
exclusive property, it is the action of the thinking power called an idea, 
which an individual may exclusively possess as long as he keeps it to 
himself; but the moment it is divulged, it forces itself into the possession 
of every one, and the receiver cannot dispossess himself of it."  -- Thomas 
Jefferson

---

## #38035 — James Dempster — 2008-05-31T17:27:49+00:00

URL: https://externals.io/message/38019#38035 · In reply to: #38034

On Sat, May 31, 2008 at 6:01 PM, Larry Garfield <larry@garfieldtech.com>
wrote:

> 
> > […]
> version.
> > […]
> Whatever
> > […]
>
> Unfortunately it probably is.  I recall someone did raise the
> ClassName::staticMethod() vs. Namespace::function() collision problem
> months
> ago, and the response at the time was "Pfft, like who uses classes and
> functions in the same project, anyway?"
>
> (Of course, the answer is "well I do" but I've long since learned that such
> answers don't carry much weight around here, so I mostly just read to see
> where the language is going rather than to influence it.  So I've just
> resigned myself to not being able to use namespaces in PHP.)
>

It's things like this that make me worry about the future of PHP. The elite
few pushing out lots of developers. :(

If namespaces are going to be problematic then lets wait for version 6.
It would also give more time for namespaces to be thought out properly.
I feel that namespaces in it's current form is a half arsed attempt to force
something into the language.


>
> --
> Larry Garfield                  AIM: LOLG42
> larry@garfieldtech.com          ICQ: 6817012
>
> "If nature has made any one thing less susceptible than all others of
> exclusive property, it is the action of the thinking power called an idea,
> which an individual may exclusively possess as long as he keeps it to
> himself; but the moment it is divulged, it forces itself into the
> possession
> of every one, and the receiver cannot dispossess himself of it."  -- Thomas
> Jefferson
>
> --
> 
> 
>
>
/James

---

## #38038 — Stanislav Malyshev — 2008-06-01T05:26:12+00:00

URL: https://externals.io/message/38019#38038 · In reply to: #38022

Hi!

> If you have to ask *me* personally, I'd not put namespaces in 5.3 and
> have a big discussion about the entire implementation. But alas.

The thing is there already were discussions. And I don't see how 
discussing endlessly but not doing anything is going to make things better.
-- 
Stanislav Malyshev, Zend Software Architect
stas@zend.com   http://www.zend.com/
(408)253-8829   MSN: stas@zend.com

---

## #38040 — Stan Vassilev | FM — 2008-06-01T06:13:19+00:00

URL: https://externals.io/message/38019#38040 · In reply to: #38038

Hi,

I'm a user-space developer. And while indeed not doing anything is annoying 
enough that I've started learning the internals of PHP, I'm not at the point 
where I can confidently submit namespace patches myself. And let's face it, 
they'll be ignored.

I would think those with the "karma" and the confidence they know better 
than the community who's vote they override all the time, would do anything, 
but ... :) ?

Regards,
Stan Vassilev

> Hi!
>
> > […]
>
> The thing is there already were discussions. And I don't see how 
> discussing endlessly but not doing anything is going to make things 
> better.
> -- 
> Stanislav Malyshev, Zend Software Architect
> stas@zend.com   http://www.zend.com/
> (408)253-8829   MSN: stas@zend.com
