Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:114055 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 10818 invoked from network); 14 Apr 2021 14:17:27 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 14 Apr 2021 14:17:27 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id B3759180507 for ; Wed, 14 Apr 2021 07:18:27 -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=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,HTML_MESSAGE, 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-lf1-f47.google.com (mail-lf1-f47.google.com [209.85.167.47]) (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 ; Wed, 14 Apr 2021 07:18:27 -0700 (PDT) Received: by mail-lf1-f47.google.com with SMTP id e14so20695235lfn.11 for ; Wed, 14 Apr 2021 07:18:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=dVA8oQ10haQ4H/0uE4ke8DB6qXI6DY2YinCYHCmiFtA=; b=J773vbpFUxMnTyQYUIry6an1EQ/KzV3fXifQttwLHpYvUpuuuhPBUPPVmMNI4I0uoN dGCnulQUjsOKxfwyfxWU8zeNCG7YssSctq5MXe0awKw9x7mJzgoiTt6IDYunJNUYWHM2 YMiAWupQ11tCrDpCZTBaPeXv+jLter4yT/egP44TfGoneXmz4NHe6KxuhM7Bj3066Hqy qyOJfXiYZZipou4AZxkAR/d1ue67rBn+O95EuzxMYXy4p94ic/Cxqd4at/Q5xuxzEfsY V/HJztHiZjUaGAX3TI3a8v6Lae7lxA2WDw7YJ7ysHjtzcUFvOvwVrjsAaGDynaQRQNOz KHxA== 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=dVA8oQ10haQ4H/0uE4ke8DB6qXI6DY2YinCYHCmiFtA=; b=PkWxZVZqYC2I6F9ccnAHWO1U+x6VLMeZBrYDEuGvZ0YK9JL4tP/8f+qwFqCsiADAdj yi8jcm4rBz30PpAQqdyFugFIPcdA+2NDokaeT4SVHLYjQPryK0srdjd4MAwzcqnUmeWX ERXmosvq4+Bh9npZDITsJVVLeJIlHgJfvawUAkdQS/eJPnmGLsr4aZdFORbtazlwCUpS 2C5DpIo0vYlR4uMynJxWuWfK2fvfEUoLWucG1abcnQRibYNay3DoGX/gG0L9oHyjv6gv wg06Pn2xSonKnH+wegS/loq3V8EEJL6n7wDmk8mS4zJqPJEdldi/prHYgBAxobNNcFwZ XwUQ== X-Gm-Message-State: AOAM532ACj2CZf0nztgjyO2GQ+l4FG6OE0TVpDdFswuPZq+9+/4i3SCS Cu3mTI+ejd4zh8UOcKWPfSr+mcNpH0StTyKoM/4= X-Google-Smtp-Source: ABdhPJwInMX706136I8+IRzXnKqrWsjiLEg7o+DAxHZXslSiHwBEnKpdKoISVooojOIp5a9gi+6qsyMW7XZjXsEWKH4= X-Received: by 2002:a05:6512:3991:: with SMTP id j17mr25917295lfu.315.1618409903222; Wed, 14 Apr 2021 07:18:23 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Wed, 14 Apr 2021 16:18:07 +0200 Message-ID: To: tyson andre Cc: "internals@lists.php.net" Content-Type: multipart/alternative; boundary="00000000000061f4f505bfef6b64" Subject: Re: [PHP-DEV] [RFC] Namespaced in bundled extensions From: nikita.ppv@gmail.com (Nikita Popov) --00000000000061f4f505bfef6b64 Content-Type: text/plain; charset="UTF-8" On Mon, Apr 5, 2021 at 8:05 PM tyson andre wrote: > > > The question of namespaces in the stdlib has been coming up a lot > recently, > > > so I'd like to present my own stab at resolving this question: > > > > > > https://wiki.php.net/rfc/namespaces_in_bundled_extensions > > > > > > Relative to a number of previous (declined) proposals, the main > difference > > > is that I do not propose a top-level "PHP\" vendor namespace, and > instead > > > recommend the use of "ExtName\", in line with existing practice for > > > extensions. I believe this addresses the primary concern with previous > > > proposals. > > > > Both of the namespacing RFCs have been announced for over 3 weeks and I > don't think I've > > seen any new discussion since then. > > Are any updates planned? When will voting on the namespacing RFC(s) > start? > > (I had some stdlib RFCs/RFC ideas I was postponing since February to > avoid interfering with the namespacing discussion) > > > > I'd love to have some more feedback on this RFC before opening voting. > There has been a lot of discussion beforehand, but only a couple responses > to this RFC... > > I didn't plan to suggest changing the direction of the RFC, so I didn't > have much to say. > I guess it's an improvement from a user perspective and that splitting > core/PECL/composer namespacing wouldn't make much sense, > especially with the ability to polyfill most core functionality in > composer packages (especially with PHP providing FFI, low level > socket/stream code, etc). > > For something like https://wiki.php.net/rfc/cachediterable I'd still be > faced with the namespacing choice among multiple options if this passed, > but choosing names for everything is out of the scope of this RFC. > > - `iterable\CachedIterable` would be the most likely, although it's also > in some ways a datastructure > - For SPL, e.g. for a new Map type or existing classes such as > SplObjectStorage, > there'd still be a number of different names such as `DataStructure\Map` > or `Collections\Map` (DS is already used by an independent PECL) > - "When adding new symbols to existing extensions, it is more important to > be consistent with existing symbols than to follow the namespacing > guidelines." > raises the question of whether existing iterables should be aliased to a > namespace around the same time > - 5 years from now we may have a different group of active voters, so if > this passed with low voting turnout > I'm not sure if there'd still be arguments over the choice to use/not > use a namespace. > Right. I think the two main things this RFC establishes is that a) yes, it *is* okay to use a namespace and b) that namespace should not have a PHP\ prefix. That still leaves you with quite a lot of different choices, but I think it removes the two most contentious issues from further discussion. > For a future iteration of https://wiki.php.net/rfc/any_all_on_iterable > it'd help if there was known community consensus (i.e. the vote on > namespaces in bundled extensions finished) > > I didn't notice before, but I assume you'd still planned to summarize > feedback so far in a discussion section before opening > https://wiki.php.net/rfc/namespaces_in_bundled_extensions > > For > https://wiki.php.net/rfc/namespaces_in_bundled_extensions#core_standard_spl > `use Array;` and `use String;` are currently syntax errors for the > unexpected token "array". > That could be fixed in the parser by adding a special case for namespace > uses, > especially now that T_NAMESPACED_NAME now allows `string\contains` to be > used without a syntax error. > Yes, those particular examples are somewhat problematic. I believe my original version of https://wiki.php.net/rfc/namespaced_names_as_token also allowed those "use" statements, so this isn't a technical problem for a new PHP version that decides to use them. It would be a problem for polyfills though, which is why we'd probably want to go for some other naming here. Say Str\contains instead of String\contains. (Worth noting that this issue also exists with "PHP\Array" before PHP 8.0, so it's not a problem that presence of a vendor prefix would resolve, outside specific cases.) > One possible concern is what would happen if PHP implemented new > functionality that overlapped with a fairly well-known PECL/Composer > package. > E.g. if there was already a FooDB\Client in a composer/PECL package, and > an independent implementation was later added to php-src, > there'd potentially be conflicting names. > Being able to implement `PHP\FooDB\Client` would avoid that ambiguity > > - Then again, other programming languages such as Python have no issue > with that, so never mind. > FooDBClient\ or Foo\ or something could probably be used. > Right. For an existing PECL extension it would be best to just bundle it instead of implementing a new one (even though that seems to be in fashion recently...) But for the more general question, we should try to be courteous and avoid collisions with important known libraries/extensions. There's usually enough leeway with naming. If worst comes to worst, you can always pull a mysql + mysqli :) > > All symbols defined in the extension should be part of the top-level > namespace or a sub-namespace. > > This should be clarified - do you mean **the extension's** top-level > namespace (e.g. OpenSSL) instead of the global namespace? I assume the > former. > Indeed, that's what I meant. I've added the extra word. Regards, Nikita --00000000000061f4f505bfef6b64--