Re: namespaces and alpha3
| From: | Steph Fox | Date: | Wed, 15 Oct 2008 14:27:11 +0000 |
| Subject: | Re: namespaces and alpha3 | ||
| References: | 1 2 3 4 5 6 7 8 9 10 11 12 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-41075@lists.php.net to get a copy of this message | ||
Hi Elizabeth,
This can be solved in three ways. 1. Greg's "leaf" solution foo::bar->baz(); - namespace foo::bar, function baz foo->bar::baz(); - namespace foo, static method bar::baz Personally I don't like this, get confusing even if we pick some weird operator like :> 2. Don't allow functions or constants in namespaces Simplest solution but appears to piss off all the people who have never actually used the current implementation or hate OO on principleNope, it's more the case that if we don't allow it we have to either say 'never' or set up an environment whereby functions and constants could be supported at a later date if need be.
3. Steph's idea - Change the separator (I vote ':::' - easy to do, similar to what we have already) foo:::bar:::baz(); - namespace foo:::bar function baz foo:::bar::baz(); - namespace foo, static method bar::baz I like this too, minus the headache of arguing over the namespace separator (again) - in a perfect world this would be a single colon, but the ternary issues (people write stupid code, so we have to cater to them) strikes again.Actually that wasn't what I meant. I meant take Greg's "leaf" solution (huh?) without the ambiguous -> part for namespace elements, and yes I'd prefer : for this too but that's dead in the water. So: foo:::bar->baz(); - namespace foo, namespace element bar->baz(); foo:::bar::baz(); - namespace foo, namespace element bar::baz(); foo:::baz(); - namespace foo, namespace element baz(); foo::bar::baz:::bat->fez(); - nested namespaces foo, bar, baz, namespace element bat->fez(); ::baz(); - global element called within namespaced code Those last two work out fine because :: is a scoping operator, not class-specific (which point it took me a while to get my head around). I think Greg's T_NS_MEMBER was the best idea ever for dealing with this sanely, he just did it so quietly we didn't notice: http://marc.info/?l=php-internals&m=122265715319308&w=2, and read all the way to the end. Taking ns elements and scope as different principles means we never get the 'dots before the eyes' issue that caused ::: to be turned down in the first place. Derick won't like ::baz() though. - Steph