Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:115566 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 9268 invoked from network); 23 Jul 2021 15:40:40 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 23 Jul 2021 15:40:40 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 072361804AA for ; Fri, 23 Jul 2021 09:06:42 -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=-1.5 required=5.0 tests=BAYES_00,KHOP_HELO_FCRDNS, SPF_HELO_NONE,SPF_NONE,UNPARSEABLE_RELAY autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS16276 94.23.0.0/16 X-Spam-Virus: No X-Envelope-From: Received: from processus.org (ns366368.ip-94-23-14.eu [94.23.14.201]) (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:06:41 -0700 (PDT) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by processus.org (Postfix) with ESMTPA id 41D335101324; Fri, 23 Jul 2021 16:06:35 +0000 (UTC) To: Levi Morrison , Theodore Brown Cc: Nicolas Grekas , PHP Internals List References: Message-ID: <77b313e3-e820-c50e-f921-40de5f41853f@processus.org> Date: Fri, 23 Jul 2021 18:06:34 +0200 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US Authentication-Results: processus.org; auth=pass smtp.auth=pierre-php@processus.org smtp.mailfrom=pierre-php@processus.org X-Spamd-Bar: / Subject: Re: [PHP-DEV] [RFC] Nullable intersection types From: pierre-php@processus.org (Pierre) Le 23/07/2021 à 17:56, Levi Morrison via internals a écrit : >> 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 with >> other languages, I don't think it's necessary to require parentheses >> 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 not reinvent a syntax that works somewhere else. And in the end, I do find this readable. (I prey that people will use space in they types definitions to make it even more readable, but style is not a topic for this RFC.) Accumulating union and sum types is probably not something I'd do every day, so in the end, I'll probably always go and read the documentation each and every time. But for people that do, they'll get used to it fast enough I think. This behavior seems fine, at least I think it's fine, as long as the documentation is clear. Regards, -- Pierre