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 principle
Nope, 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
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php