Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:113172 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 57107 invoked from network); 15 Feb 2021 01:05:36 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 15 Feb 2021 01:05:36 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id AFF24180538 for ; Sun, 14 Feb 2021 16:51:57 -0800 (PST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-Virus: No X-Envelope-From: Received: from mail-il1-f172.google.com (mail-il1-f172.google.com [209.85.166.172]) (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 ; Sun, 14 Feb 2021 16:51:56 -0800 (PST) Received: by mail-il1-f172.google.com with SMTP id q5so4186109ilc.10 for ; Sun, 14 Feb 2021 16:51:56 -0800 (PST) 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:to :cc; bh=0CNijZcfmvMj61wkz7XUsKKlw/lZveHRaPQ1w0cuzCY=; b=MJICh0MehSKiL0JE31A76nFP5ZGtoaSdIRvINQXkSGgtbFqfFo0iKEa07AueARqlaS 3t+cfkrZ3hGTGSdnz+e1UwD8sIger6kS7kZqewttjEOUx5oyDOmDPwSHFF4CASf+/3Km lMwW2liu9rOnDeVwVrv0kim08fcHMGaO3LIa4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=0CNijZcfmvMj61wkz7XUsKKlw/lZveHRaPQ1w0cuzCY=; b=mJWn2ItxUg+UBncq63nHm8GUMJgV/qXiq/knCPRifSt8b7GBo6PHg9hPlsKbbqD/7E iBHji/LF4uyZOQsAspzMEp8nIN8mpUuOtssZQdesmrpmKwToLFsgNN8a/OOzmsIoepCT tCTmyJxLXPTiFV5RCVKh/4pP2RdFIhNMJK90TPPkcriWzT3vInRAYYAWpvCncG+BSvyI uQuM1srHVdoSf1BfzCh0rwE1ZLAildFLLy8YB9fwT83T+pjsgPW9wwP7MRN/ySfKbOqX AUiF63G2YB9um1XgqTLwtGUJo8G6N8p0tKm5q2BLAzy/kG0p8oTEwg+JyFpIdWm1rCx/ phFA== X-Gm-Message-State: AOAM532F4NXRkpeAj2MaN8QskQ2As1psv58Tz+l7/nIFVI4ZSTYWS2VV OOFAn+9OdKjaBnW/FB1af/5ANR4GLS+SkWUFvfY4Zw== X-Google-Smtp-Source: ABdhPJypvCDs+w8jOtLtWzMDG4+kgQYwmXbHfPp5XfrhCHBDhfpYD5nA7rxvYosK9jYI0FxYPGZt+IwXE2XQgEk08Ko= X-Received: by 2002:a92:c26a:: with SMTP id h10mr11508599ild.234.1613350314699; Sun, 14 Feb 2021 16:51:54 -0800 (PST) MIME-Version: 1.0 References: <60256200.1c69fb81.46e68.6437SMTPIN_ADDED_MISSING@mx.google.com> <83fb79ae-13ff-09e7-83ac-3dcf4da4c3ad@processus.org> <26dffe34-135a-68c9-b202-0726f3f78d04@processus.org> In-Reply-To: Reply-To: Levi Morrison Date: Sun, 14 Feb 2021 17:51:43 -0700 Message-ID: To: tyson andre Cc: "Pierre R." , PHP internals Content-Type: text/plain; charset="UTF-8" Subject: Re: [PHP-DEV] Re: Proposal: namespace the SPL From: internals@lists.php.net ("Levi Morrison via internals") Oof, this is a long one. I'm going to snip some of it but respond to most things privately; I will also respond to some things publicly later. On Sun, Feb 14, 2021 at 3:44 PM tyson andre wrote: > > Hi internals, > > > > 1b. We may switch the direction of this alias in 9.0. > > The new names for existing Spl types at least seem more readable and possible to polyfill with `class_alias`. > It should be clarified if "data types" include interfaces such as https://www.php.net/manual/en/class.splobserver > but I assume it does. > Do you have an expected timeline for creating the RFC document for this proposal and starting the vote? > A vote would greatly reduce the uncertainty and time/energy involvement of proposing > adding additional datastructures, benefiting contributors both familiar and unfamiliar > with the PHP RFC process, and I agree with Levi that it would be useful to ensure that > "new additions going into the ext/spl can avoid having this naming discussion every time." I will write a formal RFC this week, and it will include all of the proposed aliases (unless the sentiment is that we don't want them; I talk about this a bit more later in this email). > **My main objection to the proposal is that this forces > all core generic datastructures to go in the Spl namespace > indefinitely, or would entail the creation of a separate module and splitting up the php.net manual pages to document new built-in datastructures > that don't begin with `SPL\`.** This is a logical conclusion from how it was worded, but it's not what I meant. I meant to say that ext/spl is open for contributions in certain spaces: 1. Generic data structures and their iterators. (not highly specific ones, like a hypothetical LaravelEventQueue). 2. Generic iterators. 3. File oriented types (I omitted this originally, but it was unintentional) Anyone can propose new additions to ext/spl and if they are in that scope (and maybe a few more like exceptions, we'll see), but they aren't forced to go into the SPL. It probably makes sense to add it to the SPL, but if there was a large proposal, like an iterable oriented library with over a dozen symbols, then I'm sure a case can be made for putting it somewhere else too. > If we were to enforce that all new datastructures introduced > into SPL started with `SPL` I'd have to consider moving the `CachedIterable` proposal to `ext/std` or a > new always-enabled module such as `std_ds` for classes introduced in PHP 8, > but if it turns out there's widespread support for the namespace choicing of `Spl\...ForwardArrayIterator` > I would very likely go with `Spl\...CachedIterable`. > > - I'd proposed `CachedIterable`, not `SplCachedIterable`. > - It'd force a choice between inconsistencies. In my opinion, we shouldn't be adding very many symbols to the global namespace that are unprefixed. Things should be namespaced either by using a real namespace (preferred) or by a prefix. That isn't to say I would outright ban it -- there could be perhaps new core interfaces that may make sense to go there if they interact with the language in special ways. Or at least, they belong in the global namespace by status quo until we can agree on an official namespace policy for such. > I would find it inconsistent to use the Spl naming scheme both for classes with extremely old design decisions > from php 5.3 This does not bother me, but I would also be open to not aliasing existing types if that would make people happier. If we don't alias the existing types, then there will be a small `Spl` namespace with only newer additions (which are probably of higher overall quality than the prefixed versions). I am okay with this, but sometimes people feel like this kind of thing is too small in scope. > It'd also be inconsistent to have two different sections in the PHP manual for datastructures because of a constraint on the folder `ext/spl`. > I guess phasing out `SplStack` and so on to switch to recommending brand new redesigned datastructures such as `PHP\std\Vector` or `PHP\ds\Vector` > would be another option. > - Right now, SPL is a mix of classes/interfaces/functions prefixed with Spl and those that aren't, > if you look at https://www.php.net/manual/en/book.spl.php , > SPL already has data structures such as `ArrayObject` and interfaces that aren't prefixed. Yes, the SPL is not fully consistent. Some of these things have moved out of the SPL over time (such as the Countable interface). Most data structures are prefixed, but no iterators are. In other words, it has some warts but at least mostly has a pattern going. As mentioned earlier, I think nearly all new symbols need to be namespaced or prefixed, so I think it's worth breaking the no-prefix, no-namespace tradition of the iterators for new iterator types (at least concrete ones; there may be room for new interfaces in the core language).