Re: Namespace Question - Simple
| From: | Nathan Rixham | Date: | Fri, 26 Sep 2008 12:56:06 +0000 |
| Subject: | Re: Namespace Question - Simple | ||
| References: | 1 2 | Groups: | php.internals php.internals |
| Request: | Send a blank email to internals+get-40705@lists.php.net to get a copy of this message | ||
Richard Quadling wrote:
2008/9/26 Nathan Rixham <nrixham@gmail.com>:Richard Quadling wrote: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 -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.phpFrom 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.
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
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 {in well with the PHP on Java movement. Regards, Nathan -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.phpFrom 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.
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)