# Namespace Question - Simple

- Thread: https://externals.io/message/40701
- Original archive: https://news-web.php.net/php.internals/40701
- Started by Nathan Rixham on 2008-09-26T09:57:57+00:00
- Messages: 3
- 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

---

## #40701 — Nathan Rixham — 2008-09-26T09:57:57+00:00

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

Hi All,

Can anybody answer the following question for me please.

Why not follow (exactly) Java's strong static package/namespace system 
rather than a home grown dynamic namespace system?

It works, it's common, logical, robust, a working model to follow, and 
ties in well with the PHP on Java movement.

Regards,

Nathan

---

## #40704 — Richard Quadling — 2008-09-26T11:49:23+00:00

URL: https://externals.io/message/40701#40704 · In reply to: #40701

2008/9/26 Nathan Rixham <nrixham@gmail.com>:
> Hi All,
>
> Can anybody answer the following question for me please.
>
> Why not follow (exactly) Java's strong static package/namespace system
> rather than a home grown dynamic namespace system?
>
> It works, it's common, logical, robust, a working model to follow, and ties
> in well with the PHP on Java movement.
>
> Regards,
>
> Nathan
>
> --
> 
> 
>
>

From what I understand, JAVA is compiled and PHP isn't. PHP can
include namespaces/classes/etc. at run time. Whereas everything has to
be known upfront.




-- 
-----
Richard Quadling
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
"Standing on the shoulders of some very clever giants!"

---

## #40705 — Nathan Rixham — 2008-09-26T12:56:06+00:00

URL: https://externals.io/message/40701#40705 · In reply to: #40704

Richard Quadling wrote:
> 2008/9/26 Nathan Rixham <nrixham@gmail.com>:
> > […]
> 
> From what I understand, JAVA is compiled and PHP isn't. PHP can
> include namespaces/classes/etc. at run time. Whereas everything has to
> be known upfront.
> 
> 

Richard Quadling wrote:
 > 2008/9/26 Nathan Rixham <nrixham@gmail.com>:
> > […]
and ties
> > […]
 >
 > From what I understand, JAVA is compiled and PHP isn't. PHP can
 > include namespaces/classes/etc. at run time. Whereas everything has to
 > be known upfront.
 >
 >

Thanks Richard, but you know what.. I asked completely the wrong 
question (it would appear I as everybody else, has very strong feelings 
on this); the problem/niggle here is that namespaces do not help me as a 
developer in the way they should; they're a bastardisation of namespaces 
to allow people to either - in fact I'm going to stop the ranting as 
it's pointless.

Here's what *I* /as an OO developer/ need(?want):

<?php

package com.mydom.thispackage
{
   import com.anotherdom.MysqlDbHandler as DbHandlerA;
   import com.somedom.DbHandler as DbHandlerB; # "as" makes this easier
   import com.mydom.thatpackage.RssParser; # we don't have to "as"
   import net.php.pecl.Tidy into TidySpace; # "into namespace"
   import org.nicedom.alwaysusethese.*; # why not?

   public class MyClass # visibility on classes
   {
     private $dba:DbHandlerA = new DbHandlerA();
     private $dbb:DbHandlerB = new DbHandlerB();
     protected $xmlString:String;

     public function __construct( String $xml ):void #return types
     {
       if( TidySpace::tidy_is_xml( $xml ) ) { #namespace function call
         $this->xmlString = TidySpace::tidy_repair_string( $xml );
       }
     }

   }

}
?>

think that handle's everything; encourages a fixed file hierarchy for 
classes as well which would save so many headaches; additionally allows 
for "import" instead of the pesky include/require or auto-loading.

*sorry*

php dev's if you can do the above I'll be your best friends forever.

ps: Yep I know I can avoid namespaces if I want (but can't really when 
other packages I'm using haven't avoided them..) - namespaces address a 
problem, which is there, and thus needs a solution, so will have to use 
them :)

Regards & Great Work!

Nathan

(bows out)
