Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:93273 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 68846 invoked from network); 12 May 2016 12:41:22 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 12 May 2016 12:41:22 -0000 Authentication-Results: pb1.pair.com smtp.mail=rowan.collins@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=rowan.collins@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.82.45 as permitted sender) X-PHP-List-Original-Sender: rowan.collins@gmail.com X-Host-Fingerprint: 74.125.82.45 mail-wm0-f45.google.com Received: from [74.125.82.45] ([74.125.82.45:37870] helo=mail-wm0-f45.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 71/1E-28272-1F974375 for ; Thu, 12 May 2016 08:41:22 -0400 Received: by mail-wm0-f45.google.com with SMTP id a17so133855081wme.0 for ; Thu, 12 May 2016 05:41:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-transfer-encoding; bh=VjJVlql5qTbv8Tk0yjRZ3olFI665i1VOgwGCs++duZs=; b=mwxJYa9uPYowdZvr8lX3oR9qi/rHxOmxPxE1uKN/hCmWHOcpi/YBnRfqXgWNHSmnve 8Ybh73df5a/K83W1bOTc33uDwWlgQJ7iScgrLB/IIhTejspO2xs6EZEApafYW7CIWRYM Y0x3BSsKyBaZkwdRLTSc8WXW1Zh6J2COfEricGchHvu3A1OiB8xUemqa0w0e2YR1KDMj VratSFMm6ERUWzX5BMk3YO7EClouRyHODAjBK6wR8HRuI7owy3JJTGce2s/AJWDDoBDa NPhtcoF0t+Gs1cjz8EtS9tpxC8kRojWFCmLSvzdtCPp8mkJxRdM4D26sCifHSO2aNkZq Fi7w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=VjJVlql5qTbv8Tk0yjRZ3olFI665i1VOgwGCs++duZs=; b=INArYgTwI2ZROOSCqhqupT18kbG2FUFD7nHNM72jFHZvtdN1GGziszOxG9XZckLWJv /GGT14raz8cnKfkHd6CNkV/Emg38gvqyXvxI8UHv+WePt+ZzGSkpV+fLWYvnVK77c+oX gg3cMPjTc4j7+HK8wOZWXxGxU8+7VyUjS16kWav5J9lakHmf5TSIkKGUDpQTYmDJYc31 RitK6d5yfMvwi5ft7ADxeItHxorGRHDeqG5CBHh/joG6UAg8fijnKryLzhwbn4I1tL3G j7AP7UR1WX+gIc4cTX0fQhGROiJZRW+jT6dWO0GUuFpS8JxbT3jJdkTJydT2J6GIsTlo O/3A== X-Gm-Message-State: AOPr4FVDeuAJALwXfEQsHCfoNVh8Y8M2PVPShxrSVSZZsGSBdygeO3RRt1yWbioDxSanUQ== X-Received: by 10.28.109.86 with SMTP id i83mr6232790wmc.75.1463056878452; Thu, 12 May 2016 05:41:18 -0700 (PDT) Received: from [192.168.0.98] ([93.188.182.58]) by smtp.gmail.com with ESMTPSA id g132sm13755606wme.0.2016.05.12.05.41.17 for (version=TLSv1/SSLv3 cipher=OTHER); Thu, 12 May 2016 05:41:17 -0700 (PDT) To: internals@lists.php.net References: <573232DB.8030209@lsces.co.uk> <573308EC.70502@lsces.co.uk> <57346ABE.1070509@lsces.co.uk> Message-ID: <6dabc30a-7b4b-d71c-5a64-4005fd622a2e@gmail.com> Date: Thu, 12 May 2016 13:38:47 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.0 MIME-Version: 1.0 In-Reply-To: <57346ABE.1070509@lsces.co.uk> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Re: [RFC][VOTE] Nullable Types From: rowan.collins@gmail.com (Rowan Collins) On 12/05/2016 12:36, Lester Caine wrote: > On 12/05/16 11:21, Davey Shafik wrote: >> E.g. the behavior of passing executing with a null value for the >> argument is something you should be consciously making a decision on, >> and passing in null explicitly. > > I was actually getting the logic wrong... the problem with this proposal > is that I HAVE to add the '?' for many of my libraries to continue to > work simply because they do handle the null case. So what was a working > system is broken by this change. > As I understand it, no existing code will change behaviour under this proposal. It merely adds an extra feature which libraries *can* use. What's more, it's a feature which makes those libraries *less strict*, not more. Existing code: function something(Bar $bar) {} something(new Bar); // OK something(); // Error: Missing required parameter something(null); // Error: Parameter is not of required type function something_else(Bar $bar = null) {} something_else(new Bar); // OK something_else(); // OK something_else(null); // OK None of this behaviour is going to change, no existing code will break. Now let's say the author of the something function decides to use the new nullable type hint: function something(?Bar $bar) {} something(new Bar); // OK something(); // Error: Missing required parameter something(null); // OK None of your code will be calling something(null) yet, because it was previously an error. So you now have an *extra* way of calling the function, but you don't need to change any existing usages. The only breaking change would be if the author of the something_else function decided to make the argument mandatory but nullable, so that "something_else()" would be an error, but "something_else(null)" wouldn't be. But that's just the same as if they made the argument completely mandatory - it's a breaking change in the library, not something the language change has caused to happen. Regards, -- Rowan Collins [IMSoP]