Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:125291 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 14B241A00BD for ; Mon, 26 Aug 2024 20:34:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1724704608; bh=Ky/5vtbmctHPliHexMuk5NDsyWMnzJRGkbJy1/SK1ow=; h=Date:From:To:Subject:In-Reply-To:References:From; b=YMyAH0bIzKMc4ChNDZjuuM5+3sTo0etBKEfd06nYmD47gbyRQae68IbkNDvrUYS4l LEvJ5J/nxUeXYBzfImwxikvuWFwOVQFohOKKTwbV6pyDXODTdv6IUXZPB2jmY1v+xD NaNxcVlg18vHZALGD5zJhGwT9lpZ8rHGe7Zoh/vJmEYj1mzVr6vXPy9/ZUvgw/vPye jNiwc+RYwSWWZNK9TrYAwqrkBp9vuexyRW2fbCGcuFNYKj9aWiA0200sObAilRA/3u 7mmYk+4naonvCna/f3AvVcRBG/kEZwuI2X7fCz4g875NnFZY4iOATtGFvfnU1HUD2K pa+BWgTnAAeHQ== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id CA82E18003E for ; Mon, 26 Aug 2024 20:36:47 +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.1 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_MISSING,RCVD_IN_DNSWL_LOW, SPF_HELO_PASS,SPF_PASS autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from fout3-smtp.messagingengine.com (fout3-smtp.messagingengine.com [103.168.172.146]) (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:36:47 +0000 (UTC) Received: from phl-compute-02.internal (phl-compute-02.nyi.internal [10.202.2.42]) by mailfout.nyi.internal (Postfix) with ESMTP id 24D5C1387516 for ; Mon, 26 Aug 2024 16:34:54 -0400 (EDT) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-02.internal (MEProxy); Mon, 26 Aug 2024 16:34:54 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rwec.co.uk; h=cc :content-transfer-encoding:content-type:content-type:date:date :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm1; t=1724704494; x=1724790894; bh=ApdMPW1nZSQ3I/OYu2usg4+d1ZTcvULBnrJrE/8gPL8=; b= en8O5FQogOdkfEnWMJZq2SsDL/XXLNPMNJ0+u6Mr03qVEl/uL3yYOJZOTqe+eSO8 pcBqDvBJh94XGflzI/H+5Y5Vn6FXjsO76mS0v0ghrhujw8sSX19+Z+GR7mAaorlG zwLGV0HARU64AgzBsj62fQNEV1kNMKPxiSPuMJNgG2COp1OTisow1RJVPdxbAKu0 wojbyMpd7zO8F3BM8fH//0O1IlmqwyxZwpN3rv4aHfja//JqPWCwH1G2VVrsw3AQ Qb6QKiaDRvjs9wppa7iy00ZNDWkAaY4ZMGeiEA+fvD0Ufjj1oa2Yg23vgl/ZjJpk 4bb5QmIIzPzrqgmCCW/6aA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1724704494; x= 1724790894; bh=ApdMPW1nZSQ3I/OYu2usg4+d1ZTcvULBnrJrE/8gPL8=; b=F K9+DhyuKtV3bbniUGp1HuJBVv3x1gx2CcKtLl0hYqHykSTf536/9hcZZodn3PbXP Qhq1Gpu0/7hSEPW/ajybj1inugwJ/xJ8T9cOd8EdkHZdDcEMamMhS1C3jXPaVwpi Qr2JK3fwwc9odLtLAEM9UTWRhLuq0BXsJv8NdN5o8DKpxeo759VttPqUGBiIiqAn OlCyv9g9twu9wnP2rtBbNQif9BSuqujfEI0J36GLELGlfOlhEnHLeLlrKXR7zQPi PoyFTgnY/IPqXwzSIb+LaLW9m5Zy/gGhoyR7JrcYLgVRemPDyssOqFiMkkE61BlH US5h+ypptugIZoLOLUh8A== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddruddvkedgudegkecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpggftfghnshhusghstghrihgsvgdp uffrtefokffrpgfnqfghnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivg hnthhsucdlqddutddtmdenucfjughrpeffhffvufgfjghfkfggtgfgsehtqhhmtddtreej necuhfhrohhmpedftfhofigrnhcuvfhomhhmihhnshculgfkoffuohfrngdfuceoihhmsh hophdrphhhphesrhifvggtrdgtohdruhhkqeenucggtffrrghtthgvrhhnpeehleffteei gfevudetfedugedtudevledugeeugeelheeihfehgfdtkeevvefgleenucevlhhushhtvg hrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehimhhsohhprdhphhhpsehr figvtgdrtghordhukhdpnhgspghrtghpthhtohepuddpmhhouggvpehsmhhtphhouhhtpd hrtghpthhtohepihhnthgvrhhnrghlsheslhhishhtshdrphhhphdrnhgvth X-ME-Proxy: Feedback-ID: id5114917:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA for ; Mon, 26 Aug 2024 16:34:53 -0400 (EDT) Date: Mon, 26 Aug 2024 21:34:50 +0100 To: PHP internals Subject: Re: [PHP-DEV] [RFC] Default expression User-Agent: K-9 Mail for Android In-Reply-To: References: <99846F78-38F8-4549-B0A6-6310933AA78D@newclarity.net> <0B974990-05FE-4C46-9C2B-3C243C7E8E81@getmailspring.com> <07E4ABD5-B9CE-47FA-BD9E-E42A82CFC737@newclarity.net> <4c3bc918-3aec-4cc5-b342-0924e10949bc@app.fastmail.com> Message-ID: Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable From: imsop.php@rwec.co.uk ("Rowan Tommins [IMSoP]") On 26 August 2024 20:27:59 BST, Mike Schinkel wrot= e: >So, nullable is an equivalent to the union-type concern my discussion wit= h John Coggeshall uncovered, correct?=20 It's not really anything to do with nulls, or unions=2E It's somewhat rela= ted to "contravariance of input": that it should always be safe to substitu= te a function that accepts a wider range of input=2E If you have an input "= DateTime $d", it's always safe to substitute (in a subclass, or a later ver= sion) "DateTimeInterface $d", or "?DateTime $d", or "DateTime|string $d", o= r any combination of the above=2E=20 And right now, while doing so, you can safely change the default value to = any value that is valid for the new input type, because all the caller know= s is that the parameter is optional=2E=20 For instance, "DateTime $d=3Dnew DateTime('now')" might become "DateTimeIn= terface $d=3Dnew DateTimeImmutable('now')"=2E Or maybe one subclass has "Da= teTimeInterface $d=3Dnew DateTimeImmutable('now')" and another has "DateTim= eInterface $d=3Dnew DateTime('now')"=2E >Now consider the following, assuming the RFC passed but with an added req= uirement that `match()` be used exhaustively for nullable parameters (shown= ) or parameters type hinted with unions (not shown): > >$configSource =3D new ConfigSource(default,match(default){=20 > NULL=3D>new ConfigSource->getDefaultHttpClient()->withRequestTimeoutSecs= (5), > default=3D>default->withRequestTimeoutSecs(5) >}) > >Ignoring that this expression is overly complex, if covering all "types" = would be a requirement in the RFC =E2=80=94 where `NULL` is a type here fo= r purposes of this analysis =E2=80=94can you identify another breaking chan= ge if the RFC passed? Certainly=2E A new version of the library can change the parameter to "?Ne= tworkClientInterface $httpClient=3Dnew WebSovketClient"=2E (The name kept t= he same because named parameters mean callers may be relying on it=2E) As written, it's also entirely pointless, because you've called getDefault= Client(), whose entire purpose is to be a stable public API which you can r= ely on for that purpose, rather than peeking into implementation details=2E >I did not say there was _no_ distinction, I said that we cannot be *certa= in* the values are indeed private=2E Subtle difference I admit, but there _= is_ a difference=2E :-) This is true only in the extremely pedantic sense that "we can't be certai= n that private properties are private"=2E It's not at all relevant to my ar= gument, which is that right now, the language treats default values as part= of the implementation, not part of the public API=2E >P=2ES=2E The more I think about this, the more I think that the default v= alue *should* be a formal part of the function signature=2E The fact that h= as not been explicitly defined before now =E2=80=94 due to the fact it wasn= 't relevant before this RFC =E2=80=94 does not automatically require that i= t not be a formal part of the function signature, that is just the implicit= status quo=2E This is likely something this RFC or a precursor RFC should = ask voters to vote on explicitly, and then it would be decided=2E Well, that would get an immediate "no" from me=2E I see absolutely no reas= on to restrict a function's choice of default beyond being valid for the de= clared type=2E Rowan Tommins [IMSoP]