Re: Adding `final class Deque` to PHP
| From: | Mike Schinkel | Date: | Tue, 21 Sep 2021 04:21:12 +0000 |
| Subject: | Re: Adding `final class Deque` to PHP | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-116113@lists.php.net to get a copy of this message | ||
> On Sep 19, 2021, at 8:03 PM, tyson andre <tysonandre775@hotmail.com> wrote:
>
> Hi internals,
>
> I've created a new RFC https://wiki.php.net/rfc/deque to
> add a
final class Deque
>
> This is based on the Teds\Deque implementation I've worked
> on
> for the https://github.com/TysonAndre/pecl-teds PECL.
With one caveat, this is a much stronger RFC than the Vector one. Good job!
However...
> On Sep 20, 2021, at 4:25 PM, Rowan Tommins <rowan.collins@gmail.com> wrote:
>
> On 20/09/2021 14:46, tyson andre wrote:
>> The choice of global namespace maintains consistency with the namespace used for
>> general-purpose collections already in the SPL
>
> I find this argument unconvincing. If the intention is for this to fit with existing classes in
> the SPL, it should be called "SplDeque", or more consistently
> "SplDoubleEndedQueue", and the RFC should talk about how the design aligns with those
> existing classes.
>
> If it is intended to be the first of a new set of data structures which are *not* aligned with
> the existing SPL types, then putting it in a new namespace would make most sense.
>
> In the RFC and the list you've mentioned a few comparisons, but I don't think any of
> them hold:
>
> * ArrayObject, WeakReference, and WeakMap are all classes for binding to specific engine
> behaviour, not generic data structures
> * Iterators all have an "Iterator" suffix (leading to some quite awkward names)
> * Reflection classes all have a "Reflection" prefix
> * Having both "Queue" and "SplQueue", or both "Stack" and
> "SplStack" would be a terrible idea, and is a pretty strong argument *not* to add data
> structures with such plain names
I am in complete agreement with Rowan.
Honestly, at first I confused Deque with Dequeue and was wondering why we
would name a class with a verb? It wasn't until Rowan's comment that I realized
Deque is an abbreviation.
Which begs the question: how many other PHP developers will know computer science terms like this
well enough to know Deque is a noun when they see it, and more importantly how many PHP
developers will think to search for Deque when they need a queue?
So here is a straw man argument; name the class one of:
- DataStruct\DoubleEndedQueue, or
- DataStruct\DE_Queue
Let the bike-shedding begin!
(Or is that "Let it continue?")
-Mike
P.S. BTW re: https://github.com/TysonAndre/pecl-teds <https://github.com/TysonAndre/pecl-teds>, who
is Ted? (pun intended)