Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:115538 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 63898 invoked from network); 20 Jul 2021 18:54:40 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 20 Jul 2021 18:54:40 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id F079C180508 for ; Tue, 20 Jul 2021 12:19:56 -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.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,HTML_MESSAGE, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-Virus: No X-Envelope-From: Received: from mail-il1-f174.google.com (mail-il1-f174.google.com [209.85.166.174]) (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 ; Tue, 20 Jul 2021 12:19:56 -0700 (PDT) Received: by mail-il1-f174.google.com with SMTP id y6so230065ilj.13 for ; Tue, 20 Jul 2021 12:19:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=SQllGFo7VJ9jxy0T1zBNhpazPax2zS1o2W+NPUO4+TU=; b=FNZiEil/ODrRxZYZS7woA87DAuwgOfP+HUK5oPkWTsKMXobqQy61uKWFMqW8xao9vu XVUFwVRKwIshYIxf2Hd34Kkv4cD+Iva/0U6BVQ3pnJXLeB6jrXtjAwbrJXDuUyfxOQoU 4XZ8QXj1CF/rQY6w+JEtoGcYezmhN6O47OjJmPjYNJMlTtmmpfNkP+g++YAM9SbJh+Nt OmElRwA/gZ7CvG8xqTE0alNPkmUl3ZPOilpkWRp9Emu+Af/vBTOwwtlHRHVDyIgDAx1J LWsWc1vPyCvne56mnMBDeRVg3BjVf+sxNWysy5UMCE9NRuHdt+6lkedPaRQsPyWFJMQe rY6w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=SQllGFo7VJ9jxy0T1zBNhpazPax2zS1o2W+NPUO4+TU=; b=C+u14WD7+MGSoLTiSqsdM5Rt5CIbuCcZ8snL7HVbAb1cBvBqDfPzE2klIIbtXDu8jZ mZpBEzVt/gOioRzl8CUx+lCQTVsZ73QMrrjHQ2A03E5qvN9YwplaaadcLANbQr55kJbM yAZs/wIOdo2mSy5L41/a9LfJ9Uz3/5/PFCCcM2mIlIB/v00oEjSN4AGaqEDS8euPbfxs RtyhD+aPdGgHrd1lp1PSgBmgnWsPlGGNPQq6t/jhFVpbsu/xyU3xwl0GETyOl3mF6E88 VZ8dLgjGlF9GrSVlfheTtctKNKxmCGr6aBnKFnGPJWCOlfuK+iCfbRmVSPsRdBtOV6Sc ITpw== X-Gm-Message-State: AOAM533Ip7zaHLyDP6caJeIDN7jpqiHDvnylQJPk9npQQRK1/t/zFHfk LgxJrTEPCHMW1pEHWG2uKKBEUsBw4yWGRKTvJkM= X-Google-Smtp-Source: ABdhPJyu8xFLTLC06aqCZ9jsZNz71rP1rNduto1n84EtpPhB6JTheazNt8/8FPewOD2AaUfRj+Os3pu7CduBiJEmQcU= X-Received: by 2002:a05:6e02:dc4:: with SMTP id l4mr22622764ilj.94.1626808795097; Tue, 20 Jul 2021 12:19:55 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Tue, 20 Jul 2021 21:19:43 +0200 Message-ID: To: Niklas Keller Cc: Nikita Popov , "G. P. B." , Guilliam Xavier , Dan Ackroyd , Nicolas Grekas , PHP Internals List Content-Type: multipart/alternative; boundary="00000000000059712805c792f0b5" Subject: Re: [PHP-DEV] intersection types and null for defaults, properties and return types From: deleugyn@gmail.com (Deleu) --00000000000059712805c792f0b5 Content-Type: text/plain; charset="UTF-8" On Tue, Jul 20, 2021, 20:35 Niklas Keller wrote: > > > > > > > nicolas-grekas wrote on the PR: > > > > > > ?X&Y cannot be confused with > > > > > > > > > > It confused me. A compiler might understand it, but as a human I > have > > > > > trouble understanding it. > > > > I think ?X&Y would be a pretty poor syntax choice, as it's ambiguous as > many others said: (X|null)&(Y) vs. (X&Y)|null. > > What hasn't been proposed, yet, is ?X&?Y, so requiring either all or none > of the types being nullable. > > Best, > Niklas > From the look of the syntax I would prefer it not to land on 8.1 at all, which gives us another year to think of any syntax less aggressive to the eyes. One of the things I loved about the Pure Intersection RFC was that it avoided the discussion around parenthesis on type declaration altogether. Maybe if a type alias is proposed before mingling Union and Intersection, then it's less of an aggressive syntax. Type T = (X&Y)|Z|null I don't know if anyone has offered this before, but if making an exception for nullable Intersection is on the table, what about putting the null sign at the end? X&Y&Z? It doesn't seem ambiguous because PHP defines ?X as nullable X. It doesn't seem obvious what the ? is doing at the end but at least it doesn't seem ambiguous. > --00000000000059712805c792f0b5--