Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:98223 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 80502 invoked from network); 6 Feb 2017 20:47:44 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 6 Feb 2017 20:47:44 -0000 Authentication-Results: pb1.pair.com smtp.mail=nikita.ppv@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=nikita.ppv@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.82.48 as permitted sender) X-PHP-List-Original-Sender: nikita.ppv@gmail.com X-Host-Fingerprint: 74.125.82.48 mail-wm0-f48.google.com Received: from [74.125.82.48] ([74.125.82.48:36493] helo=mail-wm0-f48.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 50/81-03389-EE0E8985 for ; Mon, 06 Feb 2017 15:47:43 -0500 Received: by mail-wm0-f48.google.com with SMTP id c85so137227588wmi.1 for ; Mon, 06 Feb 2017 12:47:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to; bh=ISGerZBe6cSxgcZJDkr5FHmb6SwODmPP5OoDiOJOMcw=; b=RhaduHUDIiR8lmGM29Kv0pQdn7gj/MQUh03ni5O1sCxLFXyuHA76RTYwBVxe9OHKwP kkhfQ7AbdWNHEVZH81cs/BifknNLnyDBQsgCxmSaCYlTxCiuTg3oK1oa8IEFGhDFSa4k RNGEw5WaLASEULcytsPDAcu0gC+vF79d+iWR+d8ABOOpGbwCGIVHi5UQfRDTcGlbnbW6 Q4RNXV7AlACPOyJryrYAjrGkcBVDvBcDVrIcpe4oEnH3yO7FGOA9gNwo2jnBQtDh2ZNl xkoMbEs2d0cVuB0Trw/fxeKwR/BRpOJ7JuZYjvhQhaecmI6j6plmrxMNWcs3BclW/YK1 tLLg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to; bh=ISGerZBe6cSxgcZJDkr5FHmb6SwODmPP5OoDiOJOMcw=; b=rUxpWH29a2SknxwgqYYDUGQK8h/4BtB1RjfFPI60utSHQ66LwVbsMc96vnOqBwUG7v v2+TI5XWwBrBl+rb51LyqpyaSJs5YTjNteraJlAkDWHp1pYYpUfKNRGLPjF9Hpu2HuyK WkboRc9XQ3lQMdiz0i4YIDB1upxEFUyySPrI93M0X+iXG29QS5Mkhq5gnDMlGDEB5rnP xeUQvbiU6NS4OftmyPznreSFiHdwhRpfP1opJCK8feehCIVo1PILa94MUKzvlMVcXQDS kb5aZFYujLn1/LZCgYBRBXFH/i2DKb0RUzhqqXVru3SeafnuxcGpCyD290rA/aH4pKj9 1/ew== X-Gm-Message-State: AMke39k7aqZwZPARweIDpI/6DXW7W6yQxcVt6p+Q1/FDuK3tuuRW0e+YfaZ+yYSCXQ3P9JaKdnfiHfqqlVH38w== X-Received: by 10.28.105.68 with SMTP id e65mr9649514wmc.44.1486414058172; Mon, 06 Feb 2017 12:47:38 -0800 (PST) MIME-Version: 1.0 Received: by 10.223.154.47 with HTTP; Mon, 6 Feb 2017 12:47:37 -0800 (PST) In-Reply-To: <459c6bef-8936-634a-9520-dbd65c35b7c7@fleshgrinder.com> References: <459c6bef-8936-634a-9520-dbd65c35b7c7@fleshgrinder.com> Date: Mon, 6 Feb 2017 21:47:37 +0100 Message-ID: To: PHP internals Content-Type: multipart/alternative; boundary=001a1147c81aed3c530547e2bd3d Subject: Re: [PHP-DEV] Namespaces in Core From: nikita.ppv@gmail.com (Nikita Popov) --001a1147c81aed3c530547e2bd3d Content-Type: text/plain; charset=UTF-8 On Mon, Feb 6, 2017 at 6:21 PM, Fleshgrinder wrote: > Hey guys! :) > > First: I like namespaces in Core but here me out! > > https://wiki.php.net/rfc/libsodium > > The second vote is clearly going to be that this new feature is added to > the core with a namespace. I already complained about this but it seems > to go unnoticed or others do not see the potential problems that might > be introduced by this. > > Sodium (or insert possible future namespace in Core here) might be a > valid username and existing community standards use the first namespace > for the vendor. Using those first level vendor namespaces in Core always > comes a long with a potential problem for users with that name. > > The PHP (case does not matter) would be the proper vendor name to put > Core stuff in, as far as I remember it is also reserved for PHP > functionality. There were also numerous discussions about providing a > cleaned up API there while maintaining backwards compatibility via > aliases and so forth in the non-namespaced Core stuff. > > Using the PHP vendor name as first level namespace would defeat problems > with userland namespaces and be a much safer choice. Hence, > `php\sodium`/`PHP\Sodium`/`Php\Sodium` would be the clear choice. > > There is another issue regarding auto-loading. If we randomly introduce > first-level namespaces we de facto make it much harder for us to exclude > some pattern from the auto-loader. However, putting everything Core > related into `Php` would mean that we can always sidestep any > auto-loader calls since we know up front that this must be a C thing. > > Most package and/or namespace system do that to avoid problems with > their users: > > - Java: `java*` > - C#: `System*` > - C++: `::std*` > - Rust: `core::*` and `std::*` [1] > - Scala: `scala*` > - Kotlin: `kotlin*` > - Ceylon: `ceylon*` > - ... > > Obviously there are some counter examples too: > > - Go: random > - Python: random > - Javascript: random > - ... > > But at least they go through an extensive standardization process where > the names are being discussed ad infinitum to ensure that they are super > generic and thus useful. It is very unlikely that `IO` or `OS` collides > with a username. > > I personally would love to see namespaces but I definitely do not want > to see random namespaces. I hope we are not going down a road that is > hard to repair later, like with so many other things we have in Core today. > > [1] Rust decided against vendor names for some reasons they explained > once in a blog post. I believe that this will become a problem for them > at some point in time since coming up with nice names over time for > users is very hard. We'll see if Rust persists and invalidates my concerns. > I'm strongly against use of the PHP namespace as a blanket namespace for bundled PHP extensions. The PHP namespace should be used only for functionality that is actually in some way related to PHP. For example, the php-ast extension could reasonably be namespaced as php\ast, as it provides an AST for PHP specifically. Similarly the tokenizer extension could reasonably be namespaced as php\tokenizer. Extensions which are not of this type should not live in the PHP namespace, because they don't have anything specifically to do with php, apart from the circumstance that they happen to be bundled at the current point in time. Remember that extension may move from being bundled to being in PECL and vice versa. If we decide to bundle the MongoDB extension with php, would we rename the currently used MongoDB namespace to PHP\MongoDB? If we decided to move it back to PECL, would the namespace go back to just MongoDB? Or would it stay PHP\MongoDB, despite not being part of PHP anymore? Should all new extensions be written with a PHP namespace to account for the possibility of the extension being bundled with PHP at a later point in time (even if there are no concrete plans to do so)? I would answer No to these questions. The namespace MongoDB is not, as you say, "random", it is *meaningful*. The namespace PHP is (with the exceptions in the first paragraph notwithstanding) meaningless and an artifact of the distribution mechanism, a mechanism which may change over time. Regards, Nikita --001a1147c81aed3c530547e2bd3d--