Re: namespace separator ideas
| From: | Jason Garber | Date: | Sat, 26 Nov 2005 21:39:44 +0000 |
| Subject: | Re: namespace separator ideas | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-20593@lists.php.net to get a copy of this message | ||
Hello,
I as a userland library author, would appreciate namespaces quite a
bit. Here is an idea:
namespace1..class()
$x = new MyApp..MemberOrder();
--
Best regards,
Jason mailto:jason@ionzoft.com
Saturday, November 26, 2005, 3:52:35 PM, you wrote:
GB> Hi all,
GB> I have only one caveat with the \ separator, which is that it is a
GB> little bit too similar to division with /, and can result in some
GB> confusing code like:
GB> <?php
GB> namespace name1 {
GB> class name2{}
GB> }
GB> define('name1', 1);
GB> define('name2', 2);
GB> $a = new name1\name2;
GB> $b = name1/name2;
?>>
GB> The same issue exists with all colon based separators (that sounds bad
GB> when read the wrong way...) because of the ternary operator, and :: with
GB> static classes/methods.
GB> <?php
GB> namespace name1 {
GB> class name2{}
GB> }
GB> define('name1', 1);
GB> define('name2', 2);
GB> // this may be a parse error with the current namespace patch,
GB> // but need not be if we use ->
GB> class name1
GB> {
GB> const name2 = 1;
GB> }
GB> $a = new name1:::name2;
GB> $b = name1::name2; // do you see the difference? I get confused
?>>
GB> What about using the T_OBJECT_OPERATOR? This is a parse error in
GB> existing versions, and also implies some separation.
GB> <?php
GB> namespace name1 {
GB> class name2{}
GB> }
GB> define('name1', 1);
GB> define('name2', 2);
GB> // this may be a parse error with the current namespace patch,
GB> // but need not be if we use ->
GB> class name1
GB> {
GB> const name2 = 1;
GB> }
$a = new name1->>name2;
GB> $b = name1::name2;
?>>
GB> I also proposed on IRC using \\ as this is similar to netware driver
GB> separators:
GB> <?php
GB> define('name1', 1);
GB> define('name2', 2);
GB> $a = new name1\\name2;
GB> $b = name1/name2;
?>>
GB> However, I know Andrei hated this :). I very much prefer the use of ->,
GB> as this has the same advantage as :: of "rhyming" with current syntax.
GB> Greg