Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:92292 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 18188 invoked from network); 14 Apr 2016 10:10:00 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 14 Apr 2016 10:10:00 -0000 Authentication-Results: pb1.pair.com header.from=me@mprelu.de; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=me@mprelu.de; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain mprelu.de from 74.201.84.163 cause and error) X-PHP-List-Original-Sender: me@mprelu.de X-Host-Fingerprint: 74.201.84.163 sender163-mail.zoho.com Received: from [74.201.84.163] ([74.201.84.163:24603] helo=sender163-mail.zoho.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 40/A7-12455-67C6F075 for ; Thu, 14 Apr 2016 06:09:59 -0400 Received: from [192.168.15.85] (88.211.97.99 [88.211.97.99]) by mx.zohomail.com with SMTPS id 1460628595180434.60516426440995; Thu, 14 Apr 2016 03:09:55 -0700 (PDT) To: internals@lists.php.net References: Message-ID: <570F6C70.7090009@mprelu.de> Date: Thu, 14 Apr 2016 11:09:52 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.7.2 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Subject: Re: [PHP-DEV] [RFC] Nullable Types From: me@mprelu.de (Matt Prelude) On 14/04/16 10:59, Davey Shafik wrote: > On Thu, Apr 14, 2016 at 2:00 AM, Derick Rethans wrote: > >> On Wed, 13 Apr 2016, Levi Morrison wrote: >> >>> As alluded to in an earlier email today[1] I am now moving the >>> Nullable Types RFC[2] to the discussion phase. In a nutshell this RFC >>> proposes syntax for declaring a type to alternatively be null. >>> >>> There is a decision that needs to be made: does the question mark go >>> before or after the type name? >>> >>> function (?Foo $foo); >>> function (Foo? $foo); >>> >>> There are precedents in several languages for each position. Some >>> relevant issues to where the question mark goes are noted in the >>> RFC[3]. >> Please put it where HHVM puts it: in front of it. Other languages are >> less of an issue than a syntax that's already used in a somewhat PHP >> language. >> >> As to the rest of the RFC: LGTM! > > I much prefer the "Nullable Foo" (?Foo) to "Foo or Null" (Foo?). I find it > easier to read. > > However, I am not a fan of introducing both this and the "Null" type for > union types — this should be the only way to create nullable types. We > already have too many things that are possible in more than one way. > > As it sits, this is purely syntactic sugar (when taken in tandem with union > types) and [if] we agree that it is good, then let us just forgo the other > syntax entirely. I'll add a little about that on the appropriate thread. > > - Davey > Also agree, the "nullable foo" reads better and has the advantage of compatibility with HHVM. The easier we make it for people to switch interpreters (and develop software which works on both interpreters) the better for PHP as a whole. Also agree that we don't need null union types if we have nullable types. - Matt