ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> php-dev
php-dev
Re: [PHP-DEV] Simple Namespace Proposal
by Guilherme Blanco other posts by this author
Jul 21 2007 11:35AM messages near this date
Re: [PHP-DEV] Simple Namespace Proposal | Re: [PHP-DEV] Simple Namespace Proposal
Sorry for posting it so late, but I would like to clarify the things
in my head. I hope a final post with compiled definitions and final
decisions is useful for other people interested in this new
functionality.


1 - The official namespace support will not use curly braces? Never or
can be in the future?

IMHO, I am +1 in this subject. A quick explanation why I am a brace's
fan. How do you declare a class?

<?php
class Foo;

public $bar = 0;

static public function test() { echo "Here Mommy!!" }

Or...

<?php

class Foo {
  public $bar = 0;
  static public function test() { echo "Here Mommy!!" }
}


I suggest to get things standard-ized. If a class uses braces,
functions uses braces, why not use braces for namespaces...?

I read in previous messages (I think from Dmitry) that you want to use
one namespace per file (and allow same namespace in multiple files),
but why should PHP control it? Keep things flexible and let the PHP
programmer decide what should he do.
If he wants to define a global function and a namespace in a single
file, it's up to him decide to do it or not.
I'll give you an example... PHP Doctrine package has a lot of files,
hundreds... there is a way to compile it in a single file, to save
some memory usage for including these files. Including a single file
is better than include hundreds, as you may know.
If you restrict it to a single namespace per file, Doctrine will load
the hundreds, and not a single one anymore. So, any effort to compile
scripts into a single file will be useless. Lukas Smith can provide
more in this subject about how Doctrine works, but I just want to
illustrate that you'll break some functionalities that current exists.


I have another questions regarding commom namespace usage... I am
interested to use, as most of all developers.


2 - Overwrite will be implemented?
Something like: overwrite function strlen( ... ) { ... }


3 - How will PHP behavior on a situation that you have a naming conflict?

Something like...

<?php
class Bar { ... }

<?php
namespace Foo {
  class Bar { ... }
}

<?php
import Foo;

$b = new Bar();


4 - Will namespaces support anything else than functions and classes
(like constants, for example)?



Thanks in advance...


Best regards,


On 7/16/07, David Zülke <dz@[...].com>  wrote:
>  As usual, consider Hans' opinion identical to mine ;) Nice job, can't
>  wait for it being out in the wild.
> 
>  David
> 
> 
>  Am 15.07.2007 um 02:37 schrieb Hans Lellelid:
> 
>  > As someone that has long clamoured for namespaces in PHP, I have to
>  > say
>  > that this proposal by Dmitry is exactly what I & others have been
>  > hoping
>  > for in PHP.  Thanks, Dmitry, for creating this patch.  I'm sure there
>  > are going to be some peculiarities that need to be sorted out, but I
>  > can't wait until we can start writing code to use this!  I am
>  > confidentl
>  > that this is something that will be embraced by the OOP PHP
>  > community as
>  > soon as it is available.
>  >
>  > Hans
>  >
>  > Andrei Zmievski wrote:
>  >> I love this. Let's ship it.
>  >>
>  >> -Andrei
>  >>
>  >>
>  >> On Jul 5, 2007, at 6:49 AM, Dmitry Stogov wrote:
>  >>
>  >>> I think the following example is much better, however I am not sure
>  >>> it's a
>  >>> right direction. Namespaces are intended to declare names that can
>  >>> conflict
>  >>> with names from other namespaces (including global namespace), do
>  >>> I am
>  >>> not
>  >>> sure that we need special keyword for internal functions.
>  >>>
>  >>> We'll think little bit more. Anyway thank you for feedback and idea.
>  >>>
>  >>> <?php
>  >>> namespace UTF8;
>  >>>
>  >>> overloaded class Exception {
>  >>> }
>  >>>
>  >>> overloaded function strlen() {
>  >>> }
>  >>> ?>
>  >>>
>  >>> Thanks. Dmitry.
>  >>>
>  >>>> -----Original Message-----
>  >>>> From: david.coallier@[...].com
>  >>>> [mailto:david.coallier@[...].com] On Behalf Of David Coallier
>  >>>> Sent: Thursday, July 05, 2007 5:35 PM
>  >>>> To: Stefan Priebsch
>  >>>> Cc: Dmitry Stogov; PHP internals
>  >>>> Subject: Re: [PHP-DEV] Simple Namespace Proposal
>  >>>>
>  >>>>
>  >>>> On 7/5/07, Stefan Priebsch <stefan.priebsch@[...].de> wrote:
>  >>>>> David Coallier schrieb:
>  >>>>>> I would probably be in favor of throwing a notice or a
>  >>>> warning when
>  >>>>>> someone modifies a built-in function (or even throw an exception)
>  >>>>>> and that way as soon as you do such thing you would know
>  >>>> right away
>  >>>>>> that you modified something and you would know where the
>  >>>>>> modification happened which would make things much easier
>  >>>> for people
>  >>>>>> developing and debugging applications.
>  >>>>>
>  >>>>> The problem is that this kind of overloading makes a nice
>  >>>> feature as
>  >>>>> well. This is runied by throwing an exception, and cautious
>  >>>> developers
>  >>>>> will at least get nervous when they see a notice.
>  >>>>>
>  >>>>> I could imagine that by adding something like "overrides foo()" or
>  >>>>> "overloads foo()" to a function/method declaration the
>  >>>> developer could
>  >>>>> make clear that he willingly overrides a built-in function, and if
>  >>>>> this is missing, an exception is being thrown. This may be a
>  >>>>> little
>  >>>>> over the top, however.
>  >>>>>
>  >>>>
>  >>>> Yep I see what you mean.. could even be something like:
>  >>>>
>  >>>> namespace UTF8;
>  >>>>
>  >>>> overrides {
>  >>>>     strlen();
>  >>>>     strcmp();
>  >>>> }
>  >>>>
>  >>>> function strlen($string)
>  >>>> {
>  >>>>     return strlen($string) + 666; // This is just an
>  >>>> example ! } ...
>  >>>>
>  >>>>
>  >>>> I kinda like the overrides part, however I wonder if people
>  >>>> will actually use it.. Oh well.. my two cents are now gone.
>  >>>>
>  >>>>
>  >>>>> Kind regards,
>  >>>>>
>  >>>>> Stefan
>  >>>>>
>  >>>>> --
>  >>>>>> e-novative> - We make IT work for you.
>  >>>>>
>  >>>>>  e-novative GmbH - HR: Amtsgericht München HRB 139407
>  >>>>>  Sitz: Wolfratshausen - GF: Dipl. Inform. Stefan Priebsch
>  >>>>>
>  >>>>>  http://www.e-novative.de
>  >>>>>
>  >>>>
>  >>>>
>  >>>>
>  >>>> --
>  >>>> David Coallier,
>  >>>> Founder & Software Architect,
>  >>>> Agora Production (http://agoraproduction.com)
>  >>>> 51.42.06.70.18
>  >>>>
>  >>>> --
>  >>>> PHP Internals - PHP Runtime Development Mailing List
>  >>>> To unsubscribe, visit: http://www.php.net/unsub.php
>  >>>>
>  >>>
>  >>> --
>  >>> PHP Internals - PHP Runtime Development Mailing List
>  >>> To unsubscribe, visit: http://www.php.net/unsub.php
>  >
>  > --
>  > PHP Internals - PHP Runtime Development Mailing List
>  > To unsubscribe, visit: http://www.php.net/unsub.php
>  >
>  >
> 
>  --
>  PHP Internals - PHP Runtime Development Mailing List
>  To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 


-- 
Guilherme Blanco - Web Developer
CBC - Certified Bindows Consultant
Cell Phone: +55 (16) 9166-6902
MSN: guilhermeblanco@[...].com
URL: http://blog.bisna.com
São Carlos - SP/Brazil
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

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved