Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:125162 X-Original-To: internals@lists.php.net Delivered-To: internals@lists.php.net Received: from php-smtp4.php.net (php-smtp4.php.net [45.112.84.5]) by qa.php.net (Postfix) with ESMTPS id ABA361A00BD for ; Fri, 23 Aug 2024 18:37:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1724438374; bh=XzaDscWbdlV2U/rc0WRWvUBnGy1Tt54EOe8EYRp4zVs=; h=Date:From:To:Cc:In-Reply-To:References:Subject:From; b=fcbncwezwzSfaBiCAssmO6kg4tMO3hCGUrdnsMEZNdhn7cpY+hJw2seXpgpnO0t3r +M+KrGYFyPngQGT8GfoON4RfVRtByVwjzplDfJl9msUE5RB+SNusmYrWUu/qHvIYGo wGaEQFoljnem9D08q+1GYQnOzEZ0OTF+xETdutjbwzF4YS0M+9OM1Rc7qVtPPf5S8z udoE1EuXRY6RoLKPBW4bKSKzFAAi2BSdmlQmTw1sWcgVS5hMR0Ak1kXYU8MXTcMIp2 9NkqYdsQZDLJXzic0T9DIVojP8cxcIdkMnpiBd1hyOhh/EVm8VXcalw9m366cnfscD vEi4aqQG8nZkg== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id C7B4D180034 for ; Fri, 23 Aug 2024 18:39:33 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DMARC_MISSING,HEADER_FROM_DIFFERENT_DOMAINS,HTML_MESSAGE, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE, SPF_NONE autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from mail-oa1-f46.google.com (mail-oa1-f46.google.com [209.85.160.46]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Fri, 23 Aug 2024 18:39:33 +0000 (UTC) Received: by mail-oa1-f46.google.com with SMTP id 586e51a60fabf-2704d461058so1586734fac.0 for ; Fri, 23 Aug 2024 11:37:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=coggenterprises-com.20230601.gappssmtp.com; s=20230601; t=1724438262; x=1725043062; darn=lists.php.net; h=mime-version:subject:references:in-reply-to:message-id:cc:to:from :date:from:to:cc:subject:date:message-id:reply-to; bh=XzaDscWbdlV2U/rc0WRWvUBnGy1Tt54EOe8EYRp4zVs=; b=rKhL4HrdPnhrR2GVdz2/kHJMzvqrQ/hrk8eo4gKU7Y2MOxRamT0wKpI/7PF/DxgV4t JvJULC82hL1AP4TLijYbu9zXqWjL7SlWGhH2ivc6HoLKiFMNlg08LdGR4G2NusdAlhBB 4l/OBX9arD3tWd+lwwKjXZD6YjF7in8Ozsyp51hq4XaRzIB6UkKeZe4lPxOhGP1AbNF3 aI9W/cj8mkoeRD+9ubNfdm+4Np18Od7YWKPLt0LF7tg2hyi11fzVC//UK3WQ3O6wgOEm Dy0pLb1Zu74R3fmzhKo+rbPJplF5WNOoD7W+GKVJNKzbfIlt783ZC9ZwF9sggiKMNbPn Cw+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724438262; x=1725043062; h=mime-version:subject:references:in-reply-to:message-id:cc:to:from :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=XzaDscWbdlV2U/rc0WRWvUBnGy1Tt54EOe8EYRp4zVs=; b=EUD+KW8qglbx2VbwN1WEz52GO8byZmVHXHAbTstM1yuDh7c6P3eGNgCJYBN8XFJbQ8 +u8X10QH0fA58z+y0a0TXwpztBf0g29/bL2TSoWi65fYVfeS2fdfVz3vykeUAcP/SPc/ agB9ZtMPKe/xV3ESfulcJPNC6854Woox//NIga1qBoH2fs8Byqpur3u7O2/6SSLqp4wT 5sSYE8ddDxBlf2OtqDju1ySGy3xA3Xdk1OqrI8R5xINxAM4VSifxw2syfBUdqK4+LB2T kbY48LlRTP9ZOKXauayiCRyaFic8uqk3aKVorxuW7eI0Y3OheotdVJBocXGrM6RDiAXp XvTg== X-Forwarded-Encrypted: i=1; AJvYcCWgibR46+67sWPKODRuGEPCQ0hY3BQJFNBDbH2IznnDSndg14BrM4RGylx6QClG6rFYHD4ikymRmQ4=@lists.php.net X-Gm-Message-State: AOJu0YwmME91VTk9QAZ6N7w1P7/+q8LbMJRtNdxFlc6hxNd2j6kcNrMM l8y9HDL6YfqqMVAWXt2G2+ti/MmAh7KGqnlxN9mmzYZxIBrq9yDoXzIhNmH9SD7BUWkTMC/H+Wy j X-Google-Smtp-Source: AGHT+IERGLmEJdAFSualBGQth6LPNPFDCcKZUnwNlW8ozzcwfTx5Qc4Us8qNuPtiytxs8huBl6v8ig== X-Received: by 2002:a05:6870:9727:b0:25e:1edb:5bcf with SMTP id 586e51a60fabf-273e63e74bcmr3761305fac.6.1724438261519; Fri, 23 Aug 2024 11:37:41 -0700 (PDT) Received: from Johns-MacBook-Pro-2.local ([207.213.210.67]) by smtp.gmail.com with ESMTPSA id 586e51a60fabf-273cebcded2sm1016238fac.54.2024.08.23.11.37.40 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 23 Aug 2024 11:37:41 -0700 (PDT) Date: Fri, 23 Aug 2024 14:37:39 -0400 To: Stephen Reay Cc: =?utf-8?Q?Rowan_Tommins_=5BIMSoP=5D?= , PHP internals Message-ID: <931B9F3E-6630-4F6A-9822-1BAC81F0643A@getmailspring.com> In-Reply-To: <6C127753-4AA4-424A-BCD4-BD4CA6FA1DB3@koalephant.com> References: <6C127753-4AA4-424A-BCD4-BD4CA6FA1DB3@koalephant.com> Subject: Re: [PHP-DEV] [Concept] Flip relative function lookup order (global, then local) X-Mailer: Mailspring Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="66c8d6f3_19495cff_15341" From: john@coggeshall.org (John Coggeshall) --66c8d6f3_19495cff_15341 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Content-Disposition: inline On Aug 23 2024, at 1:46 pm, Stephen Reay wrote: > > > The claims about "security" because a function you defined (or included via a package) is resolved in place of a global one are irrelevant. If you're including compromised code in your project, all bets are off. I have plenty of experience behind why I disagree with your dismissal here, but I'm not going to debate it with you. > > BC breaks happen. While I am all for avoiding BC breaks when possible, sometimes they make sense -- and I think this is a clear example of when it does. > > Please be specific what you mean by "this". The original proposal by Ilija provides a constant BC break over time, whenever a new global function is introduced. I don't think we're piling in functions all the time here -- and that's why we have deprecation notices when we do so we can warn users to rename a conflicting function. > > Great, so 0.24% of public packages represented, and 0% of private code represented. That certainly seems representative. Honestly, statistically it actually is fairly meaningful and representative. I have serious doubts if you went from 1000 to 10000 you'd see much change (and would welcome that information if I'm wrong). > > You've also missed the other aspect here, which I mentioned earlier: namespaced function usage is low because the language hasn't traditionally supported it anywhere near as well as namespaced classes. There have been multiple people proclaiming recently that "static utility classes" are the 'wrong' approach, that people should use namespaced functions in their code. There are two active RFCs about function autoloading. > > This change would at best, make those functions slower to use within the same namespace, and at worst, more work, with a brand new inconsistency, to use within the same namespace. The fact that functions have not been widely embraced as you argue would be an argument for having this debate now, rather than later after further adding to the complexity. > > The change we're talking about is in the range of maybe 2-4%, and is 100% solvable in userland - and has been for those 15 years, in a way that has zero impact on developers using the language to write their own functions, and is consistent with the way other symbol lookups (e.g. classes) work. I'll concede you one point. A footnote is clearly not important enough for a 2% performance benefit. Let's make it the subtext on the header of ever php.net (http://php.net) page, just to make sure people know. By this logic we shouldn't have touched list , nor should we ever add any functionality that can't be implemented in userspace using existing tools. E.g. array_column > I'm honestly not even sure where to begin here. If you add a namespaced function to your code, and call it from within that namespace, it will run. That's literally by design. If that is somehow surprising to you, I'd suggest the aforementioned name resolution page in the php manual. It's not exactly long, you can probably read it quicker than this email. You say it's by design, I say it's a bad design and should be fixed. --66c8d6f3_19495cff_15341 Content-Type: text/html; charset="utf-8" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline

On Aug 23 2024, at= 1:46 pm, Stephen Reay <php-lists=40koalephant.com> wrote:


The claims about =22security=22 because a func= tion you defined (or included via a package) is resolved in place of a gl= obal one are irrelevant. If you're including compromised code in your pro= ject, all bets are off.

I have plenty of= experience behind why I disagree with your dismissal here, but I'm not g= oing to debate it with you.

BC breaks happen. While I am all for avoiding BC breaks when poss= ible, sometimes they make sense -- and I think this is a clear example of= when it does.

Please b= e specific what you mean by =22this=22. The original proposal by Ilija pr= ovides a constant BC break over time, whenever a new global function is i= ntroduced.

I don't think we're piling in= functions all the time here -- and that's why we have deprecation notice= s when we do so we can warn users to rename a conflicting function.
=

Great, so 0.24% of public packag= es represented, and 0% of private code represented. That certainly seems = representative.

Honestly, statistically = it actually is fairly meaningful and representative. I have serious doubt= s if you went from 1000 to 10000 you'd see much change (and would welcome= that information if I'm wrong).


You'v= e also missed the other aspect here, which I mentioned earlier: namespace= d function usage is low because the language hasn't traditionally support= ed it anywhere near as well as namespaced classes. There have been multip= le people proclaiming recently that =22static utility classes=22 are the = 'wrong' approach, that people should use namespaced functions in their co= de. There are two active R=46Cs about function autoloading.
This change would at best, make those functions slower to use= within the same namespace, and at worst, more work, with a brand new inc= onsistency, to use within the same namespace.
The fact that functions have not been widely embraced as you argue = would be an argument for having this debate now, rather than later after = further adding to the complexity.


<= blockquote>
The change we're talking about is in the range of maybe 2= -4%, and is 100% solvable in userland - and has been for those 15 years, = in a way that has zero impact on developers using the language to write t= heir own functions, and is consistent with the way other symbol lookups (= e.g. classes) work. I'll concede you one point. A footnote is clearly not= important enough for a 2% performance benefit. Let's make it the subtext= on the header of ever php.net page, just to make sure people know.

By this logic we shouldn't have touched list , nor should we ever add any functionality that can't be implemen= ted in userspace using existing tools. E.g. array=5Fcolumn&n= bsp;

I'm honestly not even sure where to begin = here. If you add a namespaced function to your code, and call it from wit= hin that namespace, it will run. That's literally by design. If that is s= omehow surprising to you, I'd suggest the aforementioned name resolu= tion page in the php manual. It's not exactly long, you can probably read= it quicker than this email.

You say it's by d= esign, I say it's a bad design and should be fixed.
--66c8d6f3_19495cff_15341--