Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:92556 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 71582 invoked from network); 20 Apr 2016 16:13:37 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 20 Apr 2016 16:13:37 -0000 Authentication-Results: pb1.pair.com header.from=dmitry@zend.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=dmitry@zend.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain zend.com designates 157.56.110.106 as permitted sender) X-PHP-List-Original-Sender: dmitry@zend.com X-Host-Fingerprint: 157.56.110.106 mail-bn1bn0106.outbound.protection.outlook.com Received: from [157.56.110.106] ([157.56.110.106:40352] helo=na01-bn1-obe.outbound.protection.outlook.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 0D/DF-14036-FAAA7175 for ; Wed, 20 Apr 2016 12:13:36 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=RWSoftware.onmicrosoft.com; s=selector1-zend-com; h=From:To:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=OPS5KreGgxLhhL0nOkteX+1XhLZdTN1RDJlz0B2P2j4=; b=CoBYEniekJqDDMnnsKuhNZstx1qREipcbNXL1dNIoSvhvnsSVg+K+puInHdFLRYmrDiDeYk/mlWrcweonDY1oi9taRa34pO2n94vjeMqVj1mw6WrgmOOwxd07ORyvqiOWLQbWISuBjKMsW2JmTphn4EWaJYDlPPvtgfsO+yl7pY= Received: from BY2PR0201MB1784.namprd02.prod.outlook.com (10.163.72.26) by BY2PR0201MB1784.namprd02.prod.outlook.com (10.163.72.26) with Microsoft SMTP Server (TLS) id 15.1.466.19; Wed, 20 Apr 2016 16:13:31 +0000 Received: from BY2PR0201MB1784.namprd02.prod.outlook.com ([10.163.72.26]) by BY2PR0201MB1784.namprd02.prod.outlook.com ([10.163.72.26]) with mapi id 15.01.0466.022; Wed, 20 Apr 2016 16:13:31 +0000 To: "guilhermeblanco@gmail.com" , Lin Yo-An CC: Tom Worster , internals Thread-Topic: [PHP-DEV] [RFC] Nullable Types Thread-Index: AQHRlf/HRrhz9JlaLkGvYOd79l/iMp+JStcAgAH+hYCAAAhNm4AAiDUAgAOa/k2AAHy3AIADDrcAgAARXdw= Date: Wed, 20 Apr 2016 16:13:31 +0000 Message-ID: References: <570F4BB4.6020709@zend.com> <57112225.6020905@thefsb.org> <57119B5E.6070205@thefsb.org> , In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: thefsb.org; dkim=none (message not signed) header.d=none;thefsb.org; dmarc=none action=none header.from=zend.com; x-originating-ip: [132.245.81.165] x-ms-office365-filtering-correlation-id: 10cf36f8-8101-47d0-2624-08d36936b79f x-microsoft-exchange-diagnostics: 1;BY2PR0201MB1784;5:HDObS7kZKqepkRIZ0FVrpHURIN/4WbJeVOI1p18MbsaFmbsCBWh9OXcnhhMCuc6td4RQ0FjdR1GOLW9YsFoAb78x40Bg8nJFs4QM4kg04TGGaocrjySn4mALgzVhnxzttz7DcYlIY3jjDUWrAvTTkuLj3mSl3XqxpbJdNnZBKB6yU36+qb8mkbk8riR2Y9UE;24:R/UwPATX9pBOIEu0lZ4QCYD+k9onmUh5effvt9kzMR+9L696G9MHcFcm/FNj6BDhom0GhStlSkVrCavxVM9SbDzodBHV4Emdx37Xd2xOLE4=;7:P2u6WcJeVlE5p9/HRpYCMbkLnXl+v6fjTMDHkrCKCZwKLBbzJDBu0jQmGtboQrXCp/xdN17mQXFP3KniMor4gsLkV2j/P21DdzqAfCB9pJGqtD2qzuZtazjF3h9Yts7i9GqM12DEePSUVMFPuWwL4TTEFuPUN7LsziLONzzc8PxWF9I4hoAPdnTgOLCesdqI+BJcPP7v7gbTeJBLf4Tk9ksXKSkR/3gtYE/pn61S7V8= x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BY2PR0201MB1784; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:; x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(9101521026)(601004)(2401047)(8121501046)(5005006)(10201501046)(3002001);SRVR:BY2PR0201MB1784;BCL:0;PCL:0;RULEID:;SRVR:BY2PR0201MB1784; x-forefront-prvs: 0918748D70 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(979002)(377454003)(24454002)(5003600100002)(92566002)(11100500001)(1220700001)(77096005)(1096002)(3846002)(5004730100002)(6116002)(10400500002)(4326007)(3660700001)(189998001)(586003)(5001770100001)(9686002)(102836003)(106356001)(19580405001)(5002640100001)(54356999)(19625215002)(2906002)(3280700002)(106116001)(81166005)(19617315012)(76576001)(74316001)(19627405001)(16236675004)(33656002)(86362001)(2501003)(5880100001)(3900700001)(99286002)(2950100001)(76176999)(19580395003)(50986999)(2900100001)(15975445007)(122556002)(5008740100001)(66066001)(93886004)(87936001)(969003)(989001)(999001)(1009001)(1019001);DIR:OUT;SFP:1102;SCL:1;SRVR:BY2PR0201MB1784;H:BY2PR0201MB1784.namprd02.prod.outlook.com;FPR:;SPF:None;MLV:ovrnspm;PTR:InfoNoRecords;LANG:en; spamdiagnosticoutput: 1:23 spamdiagnosticmetadata: NSPM Content-Type: multipart/alternative; boundary="_000_BY2PR0201MB178494E8EF85885D7AB287E6BF6D0BY2PR0201MB1784_" MIME-Version: 1.0 X-OriginatorOrg: zend.com X-MS-Exchange-CrossTenant-originalarrivaltime: 20 Apr 2016 16:13:31.7151 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 32210298-c08b-4829-8097-6b12c025a892 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY2PR0201MB1784 Subject: Re: [PHP-DEV] [RFC] Nullable Types From: dmitry@zend.com (Dmitry Stogov) --_000_BY2PR0201MB178494E8EF85885D7AB287E6BF6D0BY2PR0201MB1784_ Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable What we really miss now, is an ability to define nullable return types. https://wiki.php.net/rfc/nullable_return_types I don't care about the same notations for arguments (and everything else), = because we already may use NULL default value. However usage of "?" for arguments also may make sense. Someone may like th= is, someone not. Thanks. Dmitry. ________________________________ From: guilhermeblanco@gmail.com Sent: Wednesday, April 20, 2016 18:05 To: Lin Yo-An Cc: Dmitry Stogov; Tom Worster; internals Subject: Re: [PHP-DEV] [RFC] Nullable Types I read the RFC and I want to highlight why I'll vote -1 on it even before i= t goes to voting. IMHO, it looks backwards to what the language is progressing. The introduct= ion of nullable type hint as a separate notation than a simple type hint ma= kes it *very* hard to implement typed properties, factory methods and const= ructor verifications. Dmitry is even involved in the discussion of having IS_UNDEF until construc= tor ends, then enforcing type hinting at the end of constructor to trigger = potential invalid instance state. It created a mess in the internal structu= re by creating a 3-state value: uninitialized, absent of value (null) and a= ssigned value. All this problem would be solved by merging null into accept= ed value. So far the proposed solution there to take a wrong assumption to assume a d= efault value based on type defined (like int =3D 0, string =3D '', etc), wh= ich are all potential valid values, leading to unpredictable behavior if a = develop misses to assign a value to that property. Sure, people will say that now PHP will require a NullPointerException, PHP= is turning into Java, or that I don't know what I'm talking about because = they coded for Amiga and I don't (yes, I've seen that already in this maili= ng list). But the fact is that keeping control of 3-state flags are hard to= maintain. Constructor verifications is actually a completely different subject that s= houldn't be considered as part of typed properties, but for final propertie= s (or whoever other keyword someone think is smarter because *reasons*). It= 's bad to bring this already to typed properties, specially because of its = runtime performance impact. Now let's say we move forward with nullable type hint, ignore everything wh= at I said and move forward. Congratulations, we just created a language inc= onsistency. Example: function foo(Bar $bar =3D null); Why now I have 2 ways to define a nullable value? Shouldn't this be changed= into this: function foo(?Bar $bar); But of course, changing this would be a BC break and should be left for *re= asons*. But accepting the absence of value (null) as a valid value, it woul= d address the language inconsistency (the current support would be kept, so= no BC break), and would solve a huge mess that typed properties patch curr= ently needs to solve. Ah, and we don't continue into this path of madness w= here same thing have 144 different ways in different areas to be defined. Regards, On Mon, Apr 18, 2016 at 12:24 PM, Lin Yo-An > wrote: On Mon, Apr 18, 2016 at 4:59 PM, Dmitry Stogov > wrote: > The grammar is taken from HHVM. > Using any other would make more mess. > I agree -- Guilherme Blanco Lead Architect at E-Block --_000_BY2PR0201MB178494E8EF85885D7AB287E6BF6D0BY2PR0201MB1784_--