Re: [RFC] Namespaces for internal classes
| From: | Lars Strojny | Date: | Fri, 04 Jul 2008 07:53:36 +0000 |
| Subject: | Re: [RFC] Namespaces for internal classes | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-38746@lists.php.net to get a copy of this message | ||
Hi Travis,
Am Donnerstag, den 03.07.2008, 16:31 -0500 schrieb Travis Swicegood:
>
> * Completely bike shedding, but does "Recursive" need its own level?
> RecursiveArray reads better than having Array at two different levels
> to me.
Alright, I will change that.
> * Again, bike shedding, but I like the name ArrayIterator - it
> defines exactly what the class is while Array doesn't convey very
> well by itself. You have to look at the full name in order to
> understand the process. This also becomes ambiguous when you're
> reading the code in PHP. What does "$a = new Array($some_array);"
> do?
That's what "use" is for. You would do "use Spl::Iterator::Array as
ArrayIterator" and than "new Array" becomes "new ArrayIterator" which is
pretty clear. Of course, we should add that to the docs if we go that
way.
> You end up with more verbose names by going to a PEAR1 style of
> naming convention because you have to use the entire name with the
> namespace in order to convey what the code is supposed to be doing.
> I would stick with names more closely related to the original names
> and add "spl::" (see next comment for lowerspace) to signify that
> they're part of SPL. So instead of RecursiveArrayIterator, you have
> spl::RecursiveArrayIterator; SplFileInfo becomes spl::FileInfo, etc.
I see it more as packages. "Spl" is a package consisting of several
subpackages like "Iterator", "Lists", etc. pp.
> * I would change everything except the final class name in the full
> name to be lowercase. Using your existing examples:
> Spl::List::DoublyLinked would be spl::list::DoublyLinked, or better
> yet spl::DoublyLinkedList, etc. This helps denote what is a class
> and what is part of the namespace name. In the original examples,
> its ambiguous as to what can be instantiated. Are Spl and Spl::List
> classes that can be instantiated? Moving to the lower space
> convention makes it easy to denote what is a class and what is just
> part of the namespace. This follows the path created by several
> other languages.
I don't really have an argument against that, except that I honestly
don't like it, sorry :). I'm not sure how I could assume that
"Spl::List" can be instantiated, as I miss the hint that it exists. If
Spl::List is a problem, everybody out there must have a hard time trying
to figure out that there is no StringIterator because ArrayIterator
exists?
cu, Lars
Attachment: [application/pgp-signature] Dies ist ein digital signierter Nachrichtenteil signature.asc
Attachment: [application/pgp-signature] Dies ist ein digital signierter Nachrichtenteil signature.asc