Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:116119 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 83524 invoked from network); 21 Sep 2021 20:23:38 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 21 Sep 2021 20:23:38 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id CDC3B1804DB for ; Tue, 21 Sep 2021 14:04:40 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MISSING_HEADERS, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS15169 209.85.128.0/17 X-Spam-Virus: No X-Envelope-From: Received: from mail-qk1-f169.google.com (mail-qk1-f169.google.com [209.85.222.169]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Tue, 21 Sep 2021 14:04:40 -0700 (PDT) Received: by mail-qk1-f169.google.com with SMTP id 73so2080617qki.4 for ; Tue, 21 Sep 2021 14:04:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=datadoghq.com; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:cc; bh=IBJflxFyrKX+6MIp8IwQgX1ILDjYC1+b/jd0VY0e6tU=; b=Bk7U2RfMp70qznEdTcJnctQzDfYmcYPWIuQNcIOnX6onxI8bD+E8PFIsSnplE7wFFC jdR0Yy3LaP/JS7ANn4FGgtn7uPB8XrOICgrhUwfgQ9zeZ93/gEP/O+cIKs/eOr6Vx33l MOf0B46T8GEm6SCfKj9WINSzNM0AQJzqBhHEY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:cc; bh=IBJflxFyrKX+6MIp8IwQgX1ILDjYC1+b/jd0VY0e6tU=; b=bguv9wvs6SOjefn8qZPcITV7NhgOAbxhLcnIJ72mztsWLg9PqAV7qbqzoiEaVRi+w2 ivxGqRjmkMrC7GKEVlwHr9gFPQM+ctNNdf6Y/UDOwx2zF3VD2z5mCRqOsMxJMOVINbKb duhWjb0SukHU2bpaYJugwcGG6rClmi/F8NPFTkbC/MgGzySuxnieEvO+brb75/t8+jmT ClpAwAjhHbMk6QbGvIB0k7H2D9iwxPAGJMXL18aeJs4bvoVnd/xIQLi/BeCdipgHdKEH ze2xs7VnR+I4TGCGyIPtGercJClu4LxVYqWVlGnV8DXGwA2qDehMJcL8brw6nQFMfIiM Apag== X-Gm-Message-State: AOAM532kR/xYpe4xfi/rMSHou3fU4s+ho6cSbjtjtPQ7UV56NjaeyAjx V92q8w7GS0Uz+cPl9hR0+egRbfR9OAarthyw2iZYyp1i/vof0g== X-Google-Smtp-Source: ABdhPJzDpigA5eEZb1IgscGlK3DTrx5JInk6fq4uk1AjOSWVBUq+6cCVPgGV/2n6R0U/vzSIvoYdWLMUlikpkuu385Y= X-Received: by 2002:a25:3604:: with SMTP id d4mr37096719yba.4.1632258278534; Tue, 21 Sep 2021 14:04:38 -0700 (PDT) MIME-Version: 1.0 References: <67BFE5C6-3C3F-4309-97A2-14CA0D8C3B3B@newclarity.net> <7BEE0406-3CAE-4E83-A196-F9F608BE8D17@newclarity.net> In-Reply-To: <7BEE0406-3CAE-4E83-A196-F9F608BE8D17@newclarity.net> Reply-To: Levi Morrison Date: Tue, 21 Sep 2021 15:04:27 -0600 Message-ID: Cc: PHP internals Content-Type: text/plain; charset="UTF-8" Subject: Re: [PHP-DEV] Adding `final class Deque` to PHP From: internals@lists.php.net ("Levi Morrison via internals") The name "deque" is used in the standard library of these languages: - C++: std::deque - Java: java.util.Deque (interface) - Python: collections.deque - Swift: Collections.Deque (not standard lib, apparently, but Apple official? Don't know Swift) - Rust: std::collections::VecDeque And these don't have it in the standard library: - Go - C# - C - JavaScript Anyway, it's pretty decent evidence that: 1. This functionality is pretty widely used across languages. 2. This functionality should have "deque" be in the name, or be the complete name. Discussion naming for "vector" I can understand, as it's less widely used or sometimes means something specific to numbers, but there's little point in discussing the name "deque." It's well established in programming, whether PHP programmers are aware of it or not. As I see it, the discussion should be centered around: 1. The API Deque provides. 2. The package that provides it. 3. Whether Deque's API is consistent with other structures in the same package. 4. Whether this should be included in php-src or left to extensions. I suggest that we try to make PHP as homogenous in each bullet as we can with other languages: 1. Name it "Deque." 2. Put it in the namespace "Collections" (and if included in core, then "ext/collections"). 3. Support common operations on Deque (pushing and popping items to both front and back, subscript operator works, iteration, size, etc) and add little else (don't be novel here). To me, the biggest thing left to discuss is a notion of a maximum size, which in my own experience is common for circular buffers (the implementation chosen for Deque) but not all languages have this. 4. This is less clear, but I'm in favor as long as we can provide a few other data structures at the same time. Obviously, this a voter judgement call on the yes/no. Given that I've suggested the most common options for these across many languages, it shouldn't be very controversial. The worst bit seems like picking the namespace "Collections" as this will break at least one package: https://github.com/danielgsims/php-collections. We should suggest that they vendor it anyway, as "collections" is common e.g. "Ramsey\Collections", "Doctrine\Common\Collections". I don't see a good alternative here to "Collections", as we haven't agreed on very much on past namespace proposals. Anyway, that's what I suggest.