Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:109926 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 14010 invoked from network); 29 Apr 2020 15:43:39 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 29 Apr 2020 15:43:39 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 4C1731804F8 for ; Wed, 29 Apr 2020 07:17:05 -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=-0.2 required=5.0 tests=BAYES_20,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-ASN: AS15169 209.85.128.0/17 X-Spam-Virus: No X-Envelope-From: Received: from mail-yb1-f170.google.com (mail-yb1-f170.google.com [209.85.219.170]) (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, 29 Apr 2020 07:17:04 -0700 (PDT) Received: by mail-yb1-f170.google.com with SMTP id q206so203584ybg.1 for ; Wed, 29 Apr 2020 07:17:04 -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; bh=hGAFHb/elUB5hjs77wl08ZmRDsH+XyDwrirAH9q3zmY=; b=Gs8DUiXAqURAOvDP9ZwmlOUg7tNvWIFwWLeQkFjJcbutm7HiUttH1IAr4GijkCCb/f dSBpc3LLkcg+AeZKH32YYs6i+VULLGdrgEfNtnBqJGQWnOkMCemoUAOvx5HYgiExztWt MOLUM8kZgegBtAMk9DsaH+fD1fUGNmS2P2XkH8xleClOt+f0YHF6sOYGSiNkfOCgqMMr wbnjqOxtWn24AOe2WPL77bVPq9m7brmQS9aN9/a4PzaRCJRVHz6b8jfCuXP4kEUNA/bR koE+KxElNR1KW8YmWOAUF208gusfBHxnhfl4+MVdgflVsITnSmh0Z5K+fbd+z1fmhWJ0 WC8g== 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; bh=hGAFHb/elUB5hjs77wl08ZmRDsH+XyDwrirAH9q3zmY=; b=Tye3941zOpczPVXAhn5sHFMH9qLjN0AXIyXhaeWTtvnnWiGLLU89oGdpYx28o69CQI 7kqUGdx1Za4R2j5pYYTWjaNFBuVXjoh7antrL3wpBGoQr6VEnxaW6zCJSu6RXQGqxiti lupyVS26IzfGr0PGb7HQevVIV8eMiWzSp0Jk6Gau1d+Mg1csG7MJZ4G9VkL67BbKnbiw ktQVJ+TK+7NLn1dL30DlRyNvLdMl1ARJEJp+dsVwvd0XbOi+62owdfKPsHhcheLvd7Nf uoi/mBAFro+E3goIXPj0rEDrtQ/cfH+5l/FPimwvq6lfdowa1NzNPvIM8xtmHIYHe6Sn z2yA== X-Gm-Message-State: AGi0PuYsemibCg3CF5yytHTgvDiTVBndGXSYM4jA51yR+yUpy5SL4igl Neo22OrqWesHUi7Rdh/BK1OXbY88LS0qGobkjcmXmQ== X-Google-Smtp-Source: APiQypIhmJBf9uWEIsFoOovXEov+MtQUzAyQ+v19Hz5IVgeUyPUUa6h0mQ4eZfDUXMKKNUEVO/ngDNYIN3NXDAFuTn0= X-Received: by 2002:a25:738a:: with SMTP id o132mr54859211ybc.490.1588169822943; Wed, 29 Apr 2020 07:17:02 -0700 (PDT) MIME-Version: 1.0 References: <5ea1aab8.1c69fb81.72671.791bSMTPIN_ADDED_MISSING@mx.google.com> <434969CF-4FD8-4F57-8999-92FAC43358FA@gmail.com> In-Reply-To: <434969CF-4FD8-4F57-8999-92FAC43358FA@gmail.com> Date: Wed, 29 Apr 2020 09:16:51 -0500 Message-ID: To: PHP internals Content-Type: multipart/alternative; boundary="00000000000023bb9705a46e9a73" Subject: Re: [PHP-DEV] Re: [RFC] PHP Namespace Policy From: tendoaki@gmail.com (Michael Morris) --00000000000023bb9705a46e9a73 Content-Type: text/plain; charset="UTF-8" On Sat, Apr 25, 2020 at 3:28 AM Rowan Tommins wrote: > Hi Michael, > > On 25 April 2020 00:00:32 BST, Michael Morris wrote: > >Changing function names and argument orders would lead to BC breaks so > >massive people would move away without a transition plan that was > >sustainable long term. Namespaces give that opportunity, I think. > > > You're not the first person to suggest this, indeed I've thought of trying > to write an FAQ for the list, and this would be on it. > > There is some merit to the idea, but there's a snag: just using new names > for new versions of things (which is what a new namespace would be) helps > *machines* know which is which, but it doesn't help *humans* know which is > which. Instead of "Does strpos take needle or haystack first?" the user > would now have to think "Is this file using the old or new functions? Is > one of them called str_pos and the other strpos, and do they take arguments > in a different order?" > I'm aware of this pain point, but I have to deal with it when moving between languages anyway. A project that uses both older and newer versions of the same function is going to happen regardless of the namespace it is placed in, and if namespaces aren't used then the names just keep getting longer and longer. > > The general consensus is that the long-term solution is to add new > object-oriented APIs, including "scalar objects" (syntax to call methods in > strings, integers, etc). That's not necessarily because OO is better, but > because it's sufficiently different that it can comfortably sit side by > side with the current functions. We might have > $haystack->positionOf($needle) or $needle->positionIn($haystack) or both, > and strpos would still be available to all programs with the same arguments > it's had for 20 years. > Similarly, an OO-based file handling API would give us a chance to design > in better error handling so there was no need for the @ operator and lots > of ===false checks. That new API is the kind of thing that could live under > the \PHP namespace, but the old functions wouldn't need to move anywhere. > > I like these ideas, but they don't address the point I was making I would like the old "throw it all in" approach to be moved out of \ and into \PHP\Legacy. Why? I want \ to be empty. Long term I feel this is the best approach because it matches nearly all other languages. Wouldn't that break everything? Yes, which is the reason for a mechanism to allow the user to configure which namespaces are loaded onto the root. By default, this will be /PHP/Legacy so that Legacy code will be able to run unimpeded. Or is \ itself just going to be legacy? I suppose that could be done, but functions without a namespace at all irks me. > > --00000000000023bb9705a46e9a73--