Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:125292 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 727A31A00BD for ; Mon, 26 Aug 2024 20:45:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1724705214; bh=+hHbpcsKZpnU6vTDWS+hbJ18HqTdlUJIHu4ZBJHC7+k=; h=Date:From:To:Cc:In-Reply-To:References:Subject:From; b=H17l7JF1CGYRlPqSY1THHVIIeoz1brtUpl7OKomq/XknsYNg+29EooD905GgwLi7L OEpXuKS60O4eis/1NFMHLdDPZGUAHgXuPMO0Zc2kDveC9hNVVYiZSE8n4Uu3kG7cKz fU6bHhCUKqHHxgCIOp0wnBJSnGL6NaGVs5SLLGQ2Vh4uO9AFv3e/hMF8Eyh6plCZUW y6g47jqNIa1Svrkp7Y9MQA9DlaLpCC9ynmFZ0dgO+1aA6GqpgnhinSp1SM7n5ulaSw Waz8ywscGeaIrkBsrpBJj4n3hacKaHrVOvltXye5BHB1f/c1yUkqmhCj6GkEsjN250 h+GR/eQcU2eow== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 204EF180032 for ; Mon, 26 Aug 2024 20:46:53 +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=4.1 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_H2,RCVD_IN_SBL_CSS,SPF_HELO_NONE, SPF_NONE autolearn=no autolearn_force=no version=4.0.0 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 X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Mon, 26 Aug 2024 20:46:52 +0000 (UTC) Received: by mail-yb1-f170.google.com with SMTP id 3f1490d57ef6-e16582cb9f9so3589184276.0 for ; Mon, 26 Aug 2024 13:44:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=coggenterprises-com.20230601.gappssmtp.com; s=20230601; t=1724705099; x=1725309899; 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=+hHbpcsKZpnU6vTDWS+hbJ18HqTdlUJIHu4ZBJHC7+k=; b=Kf+SE6eDUAaINg5s06pHSq+lZW4CemFK1SVBlPK6JsIGu2YRtVNfKFRC3GMXZcrC7h k0cl/kRzu5dn12819ACHU2soQ+TaMMgserZvBCi/XcWOIecbWjqN1AeV/j6JSYI2zmMw nug0g6++ogaekeekpzTq2I/NOXMbLsouI48cOwOIGw13M1TxoxW/oI6tTmYTxB/V90zG +8fxwOfj4XxPrv/xjum5+fpDP0SDLRL8+3ilZE6NihXqW98BFhTAW3c+RG/tNI5bvuvD 3X8OanM02VwU9FLA36bGpbsAiECtWs5HoFfuTzBwjJpQjz4nTHBSLRMUvqkgv7zUeyRD A3GQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724705099; x=1725309899; 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=+hHbpcsKZpnU6vTDWS+hbJ18HqTdlUJIHu4ZBJHC7+k=; b=gBHxopJRPm+0F8YEsEMHswhEsoYN732rDhJu5AGqo8Rcme/lR/018g3Jy9hLkhNT3T Qk5dbUDGD/2J5i7swc5NJWcdkePLGOLMRhGa+bZp+A12og2GfDVf/u2qQ4GCPPlDHlBU Lt1FNiOJSqkZPRrUDBOS+7eVOLL0Ry/S838sejFtt16Htu9vr8RfD39zaZSWjLFbmiMT P+HgUnPYYDhLq+TqrptxW1qMWHGwIUhMjaj9tfRK5e8tDVzpML/3MTeInmFtDpHM1orE /BwQ4Jzz8i2GY/d0ApJT6ZPS9fn1hiLiY8tNFUrp6mw27viLQ/ybVb2Xa/I9w/YSsFAF IH3w== X-Forwarded-Encrypted: i=1; AJvYcCW2V1xqup6o7sOAihA199RtC+IKV3aBKEQgdBr6dkPI3a/QH+7T4dlnDskEngack+g2VQdTkP1cEsE=@lists.php.net X-Gm-Message-State: AOJu0Yz75DtDv/fSpQvVeda9w3hYFcbJRmxLynGHbZUS6+qFZEQc1gjF pLDrete0+swuCQvJy6ldy9Ob90qaFmyIHf0i+mN+JisqsxpQft7nJnZ0tz6hloI= X-Google-Smtp-Source: AGHT+IHxIl+/hwqxbPHZOBJ34hv6xR1aLOu2C4i5vVUSpt9Ovyo3PRuqNvE1rQvOeyS+QO3G/c5gmg== X-Received: by 2002:a05:6902:2703:b0:e16:5174:fdaf with SMTP id 3f1490d57ef6-e1a2957aea5mr841129276.1.1724705098856; Mon, 26 Aug 2024 13:44:58 -0700 (PDT) Received: from Johns-MacBook-Pro-2.local ([207.213.210.67]) by smtp.gmail.com with ESMTPSA id 3f1490d57ef6-e178e68131fsm2199702276.61.2024.08.26.13.44.57 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 26 Aug 2024 13:44:58 -0700 (PDT) Date: Mon, 26 Aug 2024 16:44:57 -0400 To: Matthew Weier O'Phinney Cc: Larry Garfield , php internals Message-ID: In-Reply-To: References: Subject: Re: [PHP-DEV] [RFC] Default expression 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="66cce949_66334873_12a23" From: john@coggeshall.org (John Coggeshall) --66cce949_66334873_12a23 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Content-Disposition: inline On Aug 26 2024, at 2:11 pm, Matthew Weier O'Phinney wrote: > > I can see a few others: > > - string concatenation. I might want to prepend or append a string to a default. > > - fractional or multiplicative application, e.g. for durations/timeouts. These might require testing for non-zero first as well. I have to be honest all of these both sound like really bad practices. Maybe I'm just not being imaginative enough... but if you don't control the upstream library why would you ever trust it like that? Writing a timeout default * 0.5 when default is 1000 is a really bad way to set your timeout to 500 -- because next time you done a composer update suddenly the upstream package set the timeout to 5000 and now instead of 500 your timeout has silently become 2500. > - decorating a default instance (e.g. to lazily create a proxy without knowing the default implementation used for an argument hinted against an interface) This is exactly the usage I'm highlighted as problematic in my code example. You're introducing a new worry for the upstream API developer that doesn't need to exist, and violating a separation principle that has existed in PHP since default parameters were created 25+ years ago. > IF it's possible to accomplish, I think it's better to identify the "leaving this open will create WTF situations" than to prematurely lock _everything_ down up front. If this feature is released with an overly broad scope in terms of expressions, etc. it's not like we can take it back at that point because now people are using it in unknown ways. It is not one I'm comfortable with a "let's move forward and see what happens" approach. I don't think this RFC is anywhere near a state of being ready for a vote and I'd like to see it go back and be updated with all this feedback before we continue going back and forth on the mailing list about it. This isn't a small feature, despite the fact on the surface it seems relatively minor as compared to other things. It is introducing a whole new concept into PHP of, at least in some circumstances, suddenly making the default parameter in a function signature a formal part of it and of utmost importance that API developers have to think about changing. It's a big deal. Offhand, I am unaware of what other languages have done this or allow anything like it (are there any?) -- and there have been demonstrated real concerns backed with code examples of how this becomes problematic. Not to mention the fact it would retroactively make all default parameters in all PHP code suddenly accessible by downstream consumers in a way the author simply never intended for. As others have mentioned, this is just as big of a deal as if there was an RFC that suddenly gave developers a syntax to access object's private methods by adding ! to the property name or something (e.g. an RFC that proposed accessing private members of an object just by doing $foo->myPrivate! ). I am being left with the impression based on these emails that those in favor of this are hand-waving past some very legitimate concerns trying to push it through, rather than taking the appropriate action of accepting the feedback in the collaborative fashion it was intended and going back to the RFC to address those concerns fully. Perhaps that impression is mistaken, and if so I apologize... But to be clear I don't think there is anywhere near enough consensus on this RFC to make this a slam dunk, nor do I think it's a few tweaks away from being adoptable. --66cce949_66334873_12a23 Content-Type: text/html; charset="utf-8" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline

On Aug 26 2024, at= 2:11 pm, Matthew Weier O'Phinney <mweierophinney=40gmail.com> wrot= e:

I can see a few others:

- string concatenation. I might want to prepend or a= ppend a string to a default. 

- fractional = or multiplicative application, e.g. for durations/timeouts. These might r= equire testing for non-zero first as well.
<= br>
I have to be honest all of these both sound like really bad pract= ices. Maybe I'm just not being imaginative enough... but if you don't con= trol the upstream library why would you ever trust it like that=3F Writin= g a timeout default * 0.5  when default&nb= sp; is 1000  is a really bad way to set your timeout to= 500  -- because next time you done a composer up= date  suddenly the upstream package set the timeout to = 5000  and now instead of 500 your timeout has silently become= 2500.

- decorating a default instance = (e.g. to lazily create a proxy without knowing the default implementation= used for an argument hinted against an interface)

T= his is exactly the usage I'm highlighted as problematic in my code exampl= e. You're introducing a new worry for the upstream API developer that doe= sn't need to exist, and violating a separation principle that has existed= in PHP since default parameters were created 25+ years ago.
I=46 it's possible to accomplish, I think it's better= to identify the =22leaving this open will create WT=46 situations=22 tha= n to prematurely lock =5Feverything=5F down up front. 
<= div>
If this feature is released with an overly broad scope in te= rms of expressions, etc. it's not like we can take it back at that point = because now people are using it in unknown ways. It is not one I'm comfor= table with a =22let's move forward and see what happens=22 approach.
I don't think this R=46C is anywhere near a state of being read= y for a vote and I'd like to see it go back and be updated with all this = feedback before we continue going back and forth on the mailing list abou= t it. This isn't a small feature, despite the fact on the surface it seem= s relatively minor as compared to other things. It is introducing a whole= new concept into PHP of, at least in some circumstances, suddenly making= the default parameter in a function signature a formal part of it and of= utmost importance that API developers have to think about changing. It's= a big deal.

Offhand, I am unaware of what other languages = have done this or allow anything like it (are there any=3F) -- and there = have been demonstrated real concerns backed with code examples of how thi= s becomes problematic. Not to mention the fact it would retroactively mak= e all default parameters in all PHP code suddenly accessible by downstrea= m consumers in a way the author simply never intended for.  As other= s have mentioned, this is just as big of a deal as if there was an R=46C = that suddenly gave developers a syntax to access object's private methods= by adding =21  to the property name or something (e.g.= an R=46C that proposed accessing private members of an object just by do= ing =24foo->myPrivate=21 ).

I  am= being left with the impression based on these emails that those in favor= of this are hand-waving past some very legitimate concerns trying to pus= h it through, rather than taking the appropriate action of accepting the = feedback in the collaborative fashion it was intended and going back to t= he R=46C to address those concerns fully. Perhaps that impression is mist= aken, and if so I apologize... But to be clear I don't think there is any= where near enough consensus on this R=46C to make this a slam dunk, nor d= o I think it's a few tweaks away from being adoptable.

--66cce949_66334873_12a23--