Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:92393 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 66336 invoked from network); 18 Apr 2016 03:56:43 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 18 Apr 2016 03:56:43 -0000 Authentication-Results: pb1.pair.com header.from=larry@garfieldtech.com; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=larry@garfieldtech.com; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain garfieldtech.com from 66.111.4.26 cause and error) X-PHP-List-Original-Sender: larry@garfieldtech.com X-Host-Fingerprint: 66.111.4.26 out2-smtp.messagingengine.com Received: from [66.111.4.26] ([66.111.4.26:46742] helo=out2-smtp.messagingengine.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id A2/BF-32052-AFA54175 for ; Sun, 17 Apr 2016 23:56:42 -0400 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.nyi.internal (Postfix) with ESMTP id C62D620C14 for ; Sun, 17 Apr 2016 23:56:39 -0400 (EDT) Received: from frontend1 ([10.202.2.160]) by compute5.internal (MEProxy); Sun, 17 Apr 2016 23:56:39 -0400 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-sasl-enc:x-sasl-enc; s=smtpout; bh=lXLrdgpaE9UGzDG ZrZ85ZruuSwg=; b=r+CCtn1vNcennfCMVvGUUajGVapkuDHEAe9wo9ovF3j23v/ 5znEg7PN9UtM/XqXt+z5BqitZfJlkQdugL8CVaU8L6NjsfSWDJ/bauoeSNberPJu eqmGbJ8dU2xECBtPYPKeJSOHNNUYSL/IVy1MRNxzj/7Cr6A9J5eQ0qY4rBm8= X-Sasl-enc: 6lZRsaUFWXNIb6BbR6kVU8LAP5OE+iisIwH/JBn9HPNC 1460951799 Received: from [192.168.42.5] (c-50-178-40-84.hsd1.il.comcast.net [50.178.40.84]) by mail.messagingengine.com (Postfix) with ESMTPA id 7BF4CC00013 for ; Sun, 17 Apr 2016 23:56:39 -0400 (EDT) To: internals@lists.php.net References: <57103A46.6040803@garfieldtech.com> <5710BA79.5060108@lsces.co.uk> <57110DC5.8000007@garfieldtech.com> <571338E6.50507@fleshgrinder.com> Message-ID: <57145AF7.7060607@garfieldtech.com> Date: Sun, 17 Apr 2016 22:56:39 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.6.0 MIME-Version: 1.0 In-Reply-To: <571338E6.50507@fleshgrinder.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] [RFC] Nullable Return Type Declaration From: larry@garfieldtech.com (Larry Garfield) On 04/17/2016 02:19 AM, Fleshgrinder wrote: > Everything always has pros and cons and I do not think that there is one > answer to all of these questions. Different languages handle this > problem differently. PHP has `NULL` and we should keep it this way. To > minimize bugs resulting from unchecked `NULL` usage a compiler feature > could be implemented that warns a developer in such cases. We already > have it for uncatched exceptions (although IDEs are currently not > telling one about that; Eclipse does in Java though). Rather than debate the relative merits of Null as a concept, since I think all agree removing Null from the language is not even a thing, what do you think of my recommendation to NOT have the ? shorthand for "or null" on types, but keep the |null for union types? That is, if you want to return Foo or null, you have to use the long-hand version: function foo($a) : Foo|null That 1) Allows for explicit or-null behavior. 2) Doesn't make it quite so easy, which hopefully discourages (but does not prohibit) its usage. 3) Neatly avoids the ?Foo / Foo? question entirely. I think that's a win-win arrangement. --Larry Garfield