Re: namespace separator ideas
| From: | Jessie Hernandez | Date: | Sat, 26 Nov 2005 21:06:28 +0000 |
| Subject: | Re: namespace separator ideas | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-20587@lists.php.net to get a copy of this message | ||
I personally don't like any of these, but I just thought of this one: "%%". Don't think it'll cause any problems at all, and look at the code:
<?php
$a = new name1%%name2;
$b = name1::name2; // I see the difference clearly
?>
What do you think? ":::" is more intuitive for me, but "%%" is an acceptable alternative...
Regards,
Jessie
Greg Beaver wrote:
Hi all, I have only one caveat with the \ separator, which is that it is a little bit too similar to division with /, and can result in some confusing code like: <?php namespace name1 {class name2{}} define('name1', 1); define('name2', 2); $a = new name1\name2; $b = name1/name2; ?> The same issue exists with all colon based separators (that sounds bad when read the wrong way...) because of the ternary operator, and :: with static classes/methods. <?php namespace name1 {class name2{}} define('name1', 1); define('name2', 2); // this may be a parse error with the current namespace patch, // but need not be if we use -> class name1 {const name2 = 1;} $a = new name1:::name2; $b = name1::name2; // do you see the difference? I get confused ?> What about using the T_OBJECT_OPERATOR? This is a parse error in existing versions, and also implies some separation. <?php namespace name1 {class name2{}} define('name1', 1); define('name2', 2); // this may be a parse error with the current namespace patch, // but need not be if we use -> class name1 {const name2 = 1;} $a = new name1->name2; $b = name1::name2; ?> I also proposed on IRC using \\ as this is similar to netware driver separators: <?php define('name1', 1); define('name2', 2); $a = new name1\\name2; $b = name1/name2; ?> However, I know Andrei hated this :). I very much prefer the use of ->, as this has the same advantage as :: of "rhyming" with current syntax. Greg