Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:115567 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 11784 invoked from network); 23 Jul 2021 16:00:03 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 23 Jul 2021 16:00:03 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 21B24180503 for ; Fri, 23 Jul 2021 09:26:03 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL, SPF_HELO_PASS,SPF_NONE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS11403 66.111.0.0/20 X-Spam-Virus: No X-Envelope-From: Received: from out4-smtp.messagingengine.com (out4-smtp.messagingengine.com [66.111.4.28]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Fri, 23 Jul 2021 09:26:02 -0700 (PDT) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id DDA625C0055 for ; Fri, 23 Jul 2021 12:26:00 -0400 (EDT) Received: from imap43 ([10.202.2.93]) by compute1.internal (MEProxy); Fri, 23 Jul 2021 12:26:00 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm3; bh=ADoWxQRbOukRda2gy3JgJ1qKdMceTZIwd0kjcHN+0 QQ=; b=ip0ek7tEOnUcC+mkTDonIHHadK7zQpus0j2nGnhxP7tSkxsWrnq0ys44A 1cCTI+WM2UlshE+LQVZvtICoG0gPybFYiwS7KPxgp7vxu8LUs6ocScYbtdffZzjQ Cnig2LST2/WgcyJ4CRkfIT6Q1mWe0saiC36KcSOccGpr70Cx8lYx1kjTMqMfUs75 Hj5fLBXAyvEYF/cYZ8w003ZoUPMYj7J9cf8oeXP+vQNU+Jdaept3C8HhwsJ5Yagp CtHDM2hLYT8E5pkHKdosy8yYJa2vjrLbOHs5PAaPwMteY7R9zechlv7OpIHGJ09w HH1bkZDMu1K2D9+aE/oaKlmMNTmww== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddrfeekgdellecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefofgggkfgjfhffhffvufgtgfesthhqredtreerjeenucfhrhhomhepfdfnrghr rhihucfirghrfhhivghlugdfuceolhgrrhhrhiesghgrrhhfihgvlhguthgvtghhrdgtoh hmqeenucggtffrrghtthgvrhhnpeffffffjeffudfggeevvdeitdetvdfgjefffeffjeel feejteevheeghffhvdfgleenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmh grihhlfhhrohhmpehlrghrrhihsehgrghrfhhivghlughtvggthhdrtghomh X-ME-Proxy: Received: by mailuser.nyi.internal (Postfix, from userid 501) id 9986CAC0DD0; Fri, 23 Jul 2021 12:26:00 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.5.0-alpha0-540-g21c5be8f1e-fm-20210722.001-g21c5be8f Mime-Version: 1.0 Message-ID: In-Reply-To: <77b313e3-e820-c50e-f921-40de5f41853f@processus.org> References: <77b313e3-e820-c50e-f921-40de5f41853f@processus.org> Date: Fri, 23 Jul 2021 11:25:40 -0500 To: "php internals" Content-Type: text/plain;charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] [RFC] Nullable intersection types From: larry@garfieldtech.com ("Larry Garfield") On Fri, Jul 23, 2021, at 11:06 AM, Pierre wrote: > Le 23/07/2021 =C3=A0 17:56, Levi Morrison via internals a =C3=A9crit=C2= =A0: > >> As you note in the RFC, PHP already defines `|` as having a lower > >> precedence than `&`, so `X & Y | null` can only be interpreted as > >> `(X & Y) | null`. This is consistent with other languages such as > >> TypeScript, where `A & B | C & D` is parsed as `(A & B) | (C & D)`.= > >> [2] > >> > >> Since precedence is already defined for this syntax consistently wi= th > >> other languages, I don't think it's necessary to require parenthese= s > >> if we use the `A & B | null` syntax. > > I want to acknowledge and reject this. Few people keep the bitwise > > precedence information in their head. It's not worth it -- just > > require parenthesis. > > > I don't want to reject this, this is actually a very good point, do no= t=20 > reinvent a syntax that works somewhere else. And in the end, I do find= =20 > this readable. (I prey that people will use space in they types=20 > definitions to make it even more readable, but style is not a topic fo= r=20 > this RFC.) >=20 > Accumulating union and sum types is probably not something I'd do ever= y=20 > day, so in the end, I'll probably always go and read the documentation= =20 > each and every time. But for people that do, they'll get used to it fa= st=20 > enough I think. >=20 > This behavior seems fine, at least I think it's fine, as long as the=20= > documentation is clear. Requiring parenthesis now leaves the option open in the future to make t= hem optional when doing full mixed types. Making them optional now requires that they be optional in the future wh= en doing full mixed types. I vaguely recall there being some potential issue with making them optio= nal for full mixed intersection/union types, but not the details. Eithe= r way, it's a not-small decision to make, and may have complicated impli= cations for future work. It shouldn't be made on "eh, seems nicer" grou= nds in a post-freeze last minute RFC. Making it required now is the safer option, as it allows more flexibilit= y in the future once someone tries to implement full union/intersection = mixing. Making it optional later may still happen, I don't know, but it= doesn't box us in to requiring it later. --Larry Garfield