Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:107224 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 92952 invoked from network); 19 Sep 2019 01:26:04 -0000 Received: from unknown (HELO php-smtp3.php.net) (208.43.231.12) by pb1.pair.com with SMTP; 19 Sep 2019 01:26:04 -0000 Received: from php-smtp3.php.net (localhost [127.0.0.1]) by php-smtp3.php.net (Postfix) with ESMTP id A6AE22D20CA for ; Wed, 18 Sep 2019 16:03:34 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp3.php.net X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW, SPF_HELO_NONE,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS3301 81.224.0.0/12 X-Spam-Virus: No Received: from v-smtpout3.han.skanova.net (v-smtpout3.han.skanova.net [81.236.60.156]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by php-smtp3.php.net (Postfix) with ESMTPS for ; Wed, 18 Sep 2019 16:03:33 -0700 (PDT) Received: from [192.168.7.5] ([213.64.245.126]) by cmsmtp with ESMTPA id AiyxiLsoOXLfmAiyyiGig4; Thu, 19 Sep 2019 01:03:33 +0200 To: Nikita Popov References: Cc: PHP internals Message-ID: Date: Thu, 19 Sep 2019 01:03:30 +0200 User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-GB X-CMAE-Envelope: MS4wfEcTZPNSYYLr43ObTHET3oPHKZWF/o0EZSthVDhv+GXfSFpY2Q3JKpeRhb5dOnV6Efg8eZHCbIFrz3qHod7cDiUpB2HlxLSRsVOKPqX9iERc2t2KbGih z2uJCLmteNgZFjzdrfZxNbpp10XfESn7GR4vZrkeGP+cbsGi2o6Y4Y8Kf5XswTf6i0LHTlP5oxHwwrHnP7OOtLVPnHbmNdyNyW/uZ3l+HhYt58HYUrEUBZVL X-Envelope-From: Subject: Re: [PHP-DEV] Re: [RFC] Union Types v2 From: bjorn.x.larsson@telia.com (=?UTF-8?Q?Bj=c3=b6rn_Larsson?=) Den 2019-09-18 kl. 15:33, skrev Nikita Popov: > On Wed, Sep 4, 2019 at 10:26 AM Nikita Popov wrote: > >> Hi internals, >> >> I'd like to start the discussion on union types again, with a new proposal: >> >> Pull Request: https://github.com/php/php-rfcs/pull/1 >> Rendered Proposal: >> https://github.com/nikic/php-rfcs/blob/union-types/rfcs/0000-union-types-v2.md >> >> As an experiment, I'm submitting this RFC as a GitHub pull request, to >> evaluate whether this might be a better medium for RFC proposals in the >> future. It would be great if we could keep the discussion to the GitHub >> pull request for the purpose of this experiment (keep in mind that you can >> also create comments on specific lines in the proposal, not just the >> overall discussion thread!) Of course, you can also reply to this mail >> instead. The final vote will be held in the wiki as usual. >> >> Relatively to the previous proposal by Bob&Levi ( >> https://wiki.php.net/rfc/union_types), I think the main differences in >> this proposal are: >> * Updated to specify interaction with new language features, like full >> variance and property types. >> * Updated for the use of the ?Type syntax rather than the Type|null >> syntax. >> * Only supports "false" as a pseudo-type, not "true". >> * Slightly simplified semantics for the coercive typing mode. >> >> Regards, >> Nikita >> > Heads up, two weeks have passed, so this may now go to voting... > > I believe relative to my original draft the main change that has happened > as a result of the discussion is the use of T1|T2|null syntax instead of > ?(T1|T2) syntax for nullable types. ?T becomes an alias for T|null. People > felt fairly strongly that while ?T is a nice shorthand for a common case, > unions should use the T1|T2|null syntax that both reads better and is > already well-established from phpdoc. > > I figured I should mentioned this for people who haven't been following the > GitHub thread... > > Nikita Hi Nikita, Planned to comment on ? vs null on Github, but here it goes. Advantage with ? syntax was in my eyes that it's clear it's not a stand-alone type or what I should call it, but rather a "change/variant" to an existing type. Having it stated as T1|T2|null lead it a bit in the direction of being a more stand-alone type. Anyway, I'm quite happy with the proposal as it is. So thanks for the excellent work! r//Björn L