On Tuesday 18 July 2006 12:25, Derick Rethans wrote:
> On Tue, 18 Jul 2006, Matt Sicker wrote:
> > Maybe you might not want to include that class until PHP6.  Or, how
> > about for backwards compatibility, you do prefix the class name
> > with PHP, but when namespaces come into play, using the php
> > namespace effectively removes the PHP prefix (e.g. PHPDate ==
> > php::Date).
>
> If you rename it later it will definitely break at that moment, so
> that's a no-no.
>
> Derick
What I'm suggesting is that for PHP6, allow namespaces to be used in two 
different ways.  Example:

namespace foo {
  class bar {
    private $baz;
    static private $oof = 0;
    function __construct($baz) {
      $this->baz = $baz;
      $this->oof++; # I don't remember if you can do this, but you get
                    # the idea
    }
    static function getOof() {
      return $this->oof;
    }
  }
}

Then, we can access class `bar' like so:

$bar = new foo::bar('e.g.');
$oof = foo_bar::getOOf();

Or, you might just remove the underscore altogether so that we can 
introduce more useful namespaces (e.g. all the DOM classes can go in 
the DOM namespace).  Perhaps you could use the underscore for functions 
(!methods), thus also allowing many functions to be given their own 
namespaces (e.g. mysql_connect() == mysql::connect()).

Now since you would be able to declare something like:

using namespace mysql;

You'd be able to access its functions like so:

$db = connect('localhost', 'username', 'password') or 
die(header('HTTP/1.1 500 Internal Service Error'));

Now that might not be a good example considering mysql_* is old and 
crappy, and since using a mysqli example would be redundant since it 
already has a class, well, you know...

Anyhow, any feedback on this?  Or should I post this separately to get 
feedback since it regards PHP6?
-- 
Matt Sicker

Attachment: pgpeRNrONIK2U.pgp
Description: PGP signature

Reply via email to