Re: Re: Namespace resolution rules has been changed?
| From: | Marcin Kurzyna | Date: | Sat, 15 Nov 2008 17:07:40 +0000 |
| Subject: | Re: Re: Namespace resolution rules has been changed? | ||
| References: | 1 2 3 4 5 6 7 8 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-41926@lists.php.net to get a copy of this message | ||
"Stan Vassilev | FM" wrote:
> For me the only way to make it clear to both humans and parsers alike is
> the filepath semantics, in all places, including use. It's not perfect,
> there's no completely problem-free solution, but "prepend \ for absolute
> path" is able to become muscle memory, while other mixed solutions I've
> seen are more confusing and require more thinking: "wait in this context
> what was what?".
My point exactly. This was a real pain in the ass while converting from old
to new resolution rules (though I now this is a one-time example).
However i was explaining the new resolution rules to my co-workers recently
and it was aparent the context dependant resolution isn't clear, while
understanding: "it's always relative to current namespace" is simple and
easy. Also most people are familiar with filepath semantics so there is a
obvious point of reference (and confusion when it's not consistent).
> But this introduces a new keyword: nameof, which could clash with
> function/class/constant "nameof" in existing source code. I could suggest
[...]
> But it's definitely in-your-face issue while using namespaced code.
I'm not shure how big of a problem "nameof" clashing would be, however a way
to get fully qualified name is a nessesity in my opinion - i strugle with
this in my framework too.
Gregs suggestion of __NAMESPACE__ concatenated solution (if i understand it
correctly) isn't one accualy because __NAMESPACE__ resolves to current
namespace; and "typeof" might (and probably usually will) be used on aliased
classes not nessecerely from current namespace.
m.