Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:122731 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 432681A009C for ; Fri, 22 Mar 2024 17:47:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1711129675; bh=bcTJfqptyQLe28+sMfKYQTqy+hX2q70xNAdaLj0OovM=; h=In-Reply-To:References:Date:From:To:Cc:Subject:From; b=LKoWM0tow2R5oGcO+QsAQfhxgcjKM7eyThE2jFr5e/Pg1iMuNwnNPgqQnSW32oBZB 7TLGNYurOeWoCNYctT2eyZ6zWBE1u6i4ztpeSU7ClLMMOqEV8vafgP+rYvPqb4nwMp 68bZ/UO7FD6VFvWbL9PnKOkaam/VtgOPzSCGH03pBa+QNoOpw0bS48WtcrrLejbFs+ ZwRD6Zr1b9kNX0SgR+aj/q5eLAfLpem3PVz+aJeoiFq/76CoGjg+pmzEPiXi8EneKj tD/by15rfs5y85zm5PTLD1a1zClJzOV2yUmYKi4V/3KMre9e69ot8eoUPR8K82OOps xOj92UE53JITQ== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id D49C7180546 for ; Fri, 22 Mar 2024 17:47: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=0.6 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_MISSING,HTML_MESSAGE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from fout1-smtp.messagingengine.com (fout1-smtp.messagingengine.com [103.168.172.144]) (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, 22 Mar 2024 17:47:53 +0000 (UTC) Received: from compute6.internal (compute6.nyi.internal [10.202.2.47]) by mailfout.nyi.internal (Postfix) with ESMTP id 7DFA913800AD; Fri, 22 Mar 2024 13:47:30 -0400 (EDT) Received: from imap50 ([10.202.2.100]) by compute6.internal (MEProxy); Fri, 22 Mar 2024 13:47:30 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rwec.co.uk; h=cc :cc: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=fm2; t=1711129650; x=1711216050; bh=bcTJfqptyQ Le28+sMfKYQTqy+hX2q70xNAdaLj0OovM=; b=VE4B1BeNNaJAFGQ+uK0au5zUQf 1x98H/JFrJuKOhUZzzigm4CD8j4KXO7GVCNNEUWjuomdHxfPdNHL/ntkkuSZQC06 hiQ8QJunT7IMZ1mV7z4pPFIb+D0q7SRmxiOP9XJ3snfuRQYKSO5DRrY3CoCvTOJf HMszT52aizCPZjtW3k0UnkhjUn9cJl8RB3MhQ1+Ml3TEa9mZZWSkG+tjnkdtqa+a RmSXSyE8HTkaczBzUXJejLsu2nLXVZpncupm5T2MXDZ++Ebf9zzW2BJogItswGsW e1ODpAZsMmduHYe34bZlAc6Da6s0VjrlaWOZdW7kxo6/h9kpIqnvDDcAvFOQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc: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= fm2; t=1711129650; x=1711216050; bh=bcTJfqptyQLe28+sMfKYQTqy+hX2 q70xNAdaLj0OovM=; b=a3NtJCGNl6fKLScCUsL2BE/2vJaKfvdwBtHfzN8+h9hB KbIi8ikQvH+gOhb7IkYMHjQ44RKHdJohwY0XnbxBP//anqVJhT0PN1QzS/3b7ajr Z8alXYjDvNE6wWMUTIFzd2DFf1XaBO6EQyTPKlLPTHIEhDT3nWdtSgCCSFtPeyql O66kc/vs7Q5OlF7lqDzYG1/eMYCNF5vS5+AR7MfoHsYsy8jiyqK257j1ZgRpGtHp 7QLS0IXH5nX0dDD/vxW5I736Ez5rUZbRYOO9lYkNcCYuqqZBm39myrLONr9JoXiy cK1fEgg5CG8Lt1veur1IwOsRDNUJwB9fCqtBo0pOKQ== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledruddtvddggeduucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepofgfggfkjghffffhvfevufgtsegrtderreerreejnecuhfhrohhmpedftfho figrnhcuvfhomhhmihhnshculgfkoffuohfrngdfuceoihhmshhophdrphhhphesrhifvg gtrdgtohdruhhkqeenucggtffrrghtthgvrhhnpeduuedvkeffgefghfevkedvfefgudff gfefheduhefgfeehgfekleelfeekteehteenucevlhhushhtvghrufhiiigvpedtnecurf grrhgrmhepmhgrihhlfhhrohhmpehimhhsohhprdhphhhpsehrfigvtgdrtghordhukh X-ME-Proxy: Feedback-ID: id5114917:Fastmail Received: by mailuser.nyi.internal (Postfix, from userid 501) id 27C291700093; Fri, 22 Mar 2024 13:47:30 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.11.0-alpha0-332-gdeb4194079-fm-20240319.002-gdeb41940 Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net MIME-Version: 1.0 Message-ID: In-Reply-To: References: <3F78A125-1946-42E2-A4F5-A2B282BE2107@rwec.co.uk> <2d7ec203-6e80-445c-94f4-d29ef58743b1@rwec.co.uk> <7d53f2e4-46f3-46f1-89b0-6e1d3b0b2e32@app.fastmail.com> Date: Fri, 22 Mar 2024 17:46:27 +0000 To: "Claude Pache" Cc: internals@lists.php.net Subject: Re: [PHP-DEV] Proposal: AS assertions Content-Type: multipart/alternative; boundary=829783136aef4979a83e53d1d6095779 From: imsop.php@rwec.co.uk ("Rowan Tommins [IMSoP]") --829783136aef4979a83e53d1d6095779 Content-Type: text/plain;charset=utf-8 Content-Transfer-Encoding: quoted-printable On Fri, 22 Mar 2024, at 17:38, Claude Pache wrote: >=20 >> Le 22 mars 2024 =C3=A0 16:18, Rowan Tommins [IMSoP] a =C3=A9crit : >>=20 >> $optionalExpiryDateTime =3D $expiry as ?DateTimeInterface else some_o= ther_function($expiry); >> assert($optionalExpiryDateTime is ?DateTimeInterface); // cannot fail= , already asserted by the "as" >=20 > I think that the `is` operator is all we need; the `as` operator adds = syntax complexity for little gain. Compare: >=20 > $optionalExpiryDateTime =3D $expiry as ?DateTimeInterface else some_ot= her_function($expiry); >=20 > vs >=20 > $optionalExpiryDateTime =3D $expiry is ?DateTimeInterface ? $expiry : = some_other_function($expiry); I agree, it doesn't add much; and that's what the draft RFC Ilija linked= to says as well. But the point of that particular example is that after the "is" version,= you don't actually know the type of $optionalExpiryDateTime without loo= king up the return type of some_other_function() With the "as" version, you can see at a glance that after that line, $op= tionalExpiryDateTime is *guaranteed* to be DateTimeInterface or null, wh= ich I understood to be the intention of Robert's original proposal on th= is thread. --=20 Rowan Tommins [IMSoP] --829783136aef4979a83e53d1d6095779 Content-Type: text/html;charset=utf-8 Content-Transfer-Encoding: quoted-printable
On Fri, 22 Mar = 2024, at 17:38, Claude Pache wrote:

Le 22 mars 2024 =C3=A0 16:18, Rowan Tommins [IMS= oP] <imsop.php@rwec.co.uk> a =C3=A9crit :

=
$optionalExpiryDat= eTime =3D $expiry as ?DateTimeInterface else some_other_function($expiry= );
assert($optionalExpiryDateTime is ?DateTimeInterface); // cann= ot fail, already asserted by the "as"

I think that the `is` operator = is all we need; the `as` operator adds syntax complexity for little gain= . Compare:

$optionalExpiryDateTime =3D $exp= iry as ?DateTimeInterface else some_other_function($expiry);

vs

$optionalExpiryDateTim= e =3D $expiry is ?DateTimeInterface ? $expiry : some_other_function($exp= iry);


I agree, = it doesn't add much; and that's what the draft RFC Ilija linked to says = as well.

But the point of that particular e= xample is that after the "is" version, you don't actually know the type = of $optionalExpiryDateTime without looking up the return type of some_ot= her_function()

With the "as" version, you c= an see at a glance that after that line, $optionalExpiryDateTime is *gua= ranteed* to be DateTimeInterface or null, which I understood to be the i= ntention of Robert's original proposal on this thread.
--
Rowan Tommins
[IMSoP]

--829783136aef4979a83e53d1d6095779--