Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:125240 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 E94041A00BD for ; Sun, 25 Aug 2024 21:09:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1724620293; bh=oinw/qroDfATpFEItCIUu2XpwQno7oZ89505N0QQmgo=; h=Date:From:To:Subject:In-Reply-To:References:From; b=kXUMxP9e422BmKApcAw2fzZEyO86BP/bC0HxoRDtrKsUXrnCmjKiJXlsEnTdCD9fr BnP38X1SzYR3x06NxBUjXmRxXugHZrGEv5L8HxW95qPTiUb+IqQKLWOSTd4GANE31A 2Vh1lKjKT9sx11iQxMyFBuzQNxh8WNvjWkb4w1mOL5SxyanijuaU4yyta5XEp9dYg4 RdztghJ5VvlPpfiV0GNKjBKbeZLvH1goNwVU36XyxskBM/jYjP635LuK9KoHIcEzpd b5wuOCvQxfOELlYKfdVLwSAoG9QivSGuulN4Y7Qkj9MgCjg6dtfBkjX02h/vOcMp5J GbCnSZhZMXodw== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 2E3AD180059 for ; Sun, 25 Aug 2024 21:11:32 +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 fhigh7-smtp.messagingengine.com (fhigh7-smtp.messagingengine.com [103.168.172.158]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Sun, 25 Aug 2024 21:11:31 +0000 (UTC) Received: from phl-compute-08.internal (phl-compute-08.nyi.internal [10.202.2.48]) by mailfhigh.nyi.internal (Postfix) with ESMTP id DB567114EBA1 for ; Sun, 25 Aug 2024 17:09:38 -0400 (EDT) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-08.internal (MEProxy); Sun, 25 Aug 2024 17:09:38 -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=1724620178; x=1724706578; bh=oinw/qroDfATpFEItCIUu2XpwQno7oZ89505N0QQmgo=; b= F5Uz571sDgUBJS8kJqmpU+1AhglS2pgQVJNqqPC9AUwL1BoyXD1ST6r0ilqW5my9 J7yk+WsCEDdqPx6EXNz5+nwkOVXNflazy17l1TVwM0Ragsq9MIq5om1nzpfEfQme WprIIK/PBVYMFTvWdJOeQ1+9f1Vq8KBEkTt57KGCty9EjsgbH5FxRCI/M53oAnBl MlAWTnjyTqUspblVUThp46Plhfn3AAeicgrAZuv5CzTRwFoRXepiHC1xOUQu1H+S WPyBcKXEdiWOaYDwbMNwSY4MeHq0jJ85anSoiYMuWAT37J8+X6sQdaAlOraUIUQM 9T0B5TqhcTnBuTCXY8Mtkw== 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=1724620178; x= 1724706578; bh=oinw/qroDfATpFEItCIUu2XpwQno7oZ89505N0QQmgo=; b=Z feLeFnTagLoNcFdzDuxe4sgdcy0tm7hzzTpp7ih7qCD6jv1co9dhoP3RW9CHFtSe KD6eOGjctIsWm3Gd695YprsE6yfxcZUsUSATZ5nmjHT+lEsMUCNJgJ0ioSTbvzg1 hHQsxed/Uvs3InAL6H1Hr9gzlUzAWTSmatnRMawRmXlntL3D3o1Kn0saKFmInZrH kmw2oDdrjmsvNnrU0lEUGEJNN8jf1t+lTGJVU6+w3bXbTGqbdiUcfla20VvF7v5v Iv8rFcDOrjT4byDUqD4vfvwnrrgeUAMXgvNVYkdWnAGhHUzYwvx241ZLOS3GV/6a LdKS5JZYL29yIPZxXG4kw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddruddviedgudehiecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpggftfghnshhusghstghrihgsvgdp uffrtefokffrpgfnqfghnecuuegrihhlohhuthemuceftddtnecunecujfgurhepfffhvf fufggjfhfkgggtgfesthhqmhdttderjeenucfhrhhomhepfdftohifrghnucfvohhmmhhi nhhsucglkffoufhorfgnfdcuoehimhhsohhprdhphhhpsehrfigvtgdrtghordhukheqne cuggftrfgrthhtvghrnhepheelffetiefgveduteefudegtdduveeludegueegleehiefh hefgtdekveevgfelnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilh hfrhhomhepihhmshhophdrphhhphesrhifvggtrdgtohdruhhkpdhnsggprhgtphhtthho pedupdhmohguvgepshhmthhpohhuthdprhgtphhtthhopehinhhtvghrnhgrlhhssehlih hsthhsrdhphhhprdhnvght X-ME-Proxy: Feedback-ID: id5114917:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA for ; Sun, 25 Aug 2024 17:09:38 -0400 (EDT) Date: Sun, 25 Aug 2024 22:09:36 +0100 To: internals@lists.php.net Subject: Re: [PHP-DEV] [RFC] Default expression User-Agent: K-9 Mail for Android In-Reply-To: <6afeb23a-867f-457d-9b13-fdf5af02c31e@scriptfusion.com> References: <0c8ed5d6-5507-4c41-8d7f-05d14ba8aa4c@scriptfusion.com> <0cfd3a28-3cb0-4478-85fb-cf086d8e5c66@app.fastmail.com> <3e0d031e-256f-47cd-9a2b-dcdc760f5498@scriptfusion.com> <6afeb23a-867f-457d-9b13-fdf5af02c31e@scriptfusion.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 25 August 2024 21:00:03 BST, Bilge wrote: >class Suspension { >=C2=A0=C2=A0=C2=A0 /** >=C2=A0=C2=A0=C2=A0=C2=A0 * @param int $delay Specifies the delay in milli= seconds=2E >=C2=A0=C2=A0=C2=A0=C2=A0 */ >=C2=A0=C2=A0=C2=A0 public function suspend(int $delay =3D 1_000) { >=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 var_dump($delay); >=C2=A0=C2=A0=C2=A0 } >} > >class MySuspension extends Suspension { >=C2=A0=C2=A0=C2=A0 /** >=C2=A0=C2=A0=C2=A0=C2=A0 * @param float|int|null $delay Specifies the del= ay in seconds=2E >=C2=A0=C2=A0=C2=A0=C2=A0 */ >=C2=A0=C2=A0=C2=A0 public function suspend(float|int|null $delay =3D null= ) { >=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 parent::suspend((int)(($delay = ?? 0) * 1000) ?: default); >=C2=A0=C2=A0=C2=A0 } >} > >new MySuspension()->suspend(2=2E2345); // int(2234) > >Not only have I demonstrated the need to use multiplication or division t= o change the scale, but also the need to cast=2E Possibly something got lost as you redrafted the example, because as you'v= e written it, neither the multiplication nor the cast are applied to the va= lue looked up by "default"=2E The parameter reduces to "(expression) ?: def= ault", which I've already agreed is useful=2E I was thinking about why "bitwise or" feels so different from other operat= ors here, and I realised it's because it's idempotent (I hope I'm using tha= t term correctly): if the specified bits are already set, it will have no e= ffect=2E Consequently, we know that ($x | SOME_FLAG) & SOME_FLAG =3D=3D=3D SOME_FLA= G without knowing the value of $x=2E That in turn means that regardless of = how the default value changes in future, we know what "default | JSON_PRETT= Y_PRINT" will do=2E It's as though each bit flag is a separate parameter, and you're saying "p= ass true to $prettyPrint, but let the implementation decide sensible defaul= ts for all other flags"=2E The majority of operators don't have that property, so they require some a= dditional assumptions about the default, which might not hold in future=2E = For instance, if you use "default + 1", you are implicitly assuming that th= e default value is not the maximum allowed value=2E Rowan Tommins [IMSoP]