Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:92305 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 52579 invoked from network); 14 Apr 2016 16:35:50 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 14 Apr 2016 16:35:50 -0000 Authentication-Results: pb1.pair.com smtp.mail=morrison.levi@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=morrison.levi@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.192.193 as permitted sender) X-PHP-List-Original-Sender: morrison.levi@gmail.com X-Host-Fingerprint: 209.85.192.193 mail-pf0-f193.google.com Received: from [209.85.192.193] ([209.85.192.193:33869] helo=mail-pf0-f193.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 5F/04-25796-4E6CF075 for ; Thu, 14 Apr 2016 12:35:48 -0400 Received: by mail-pf0-f193.google.com with SMTP id d184so7540991pfc.1 for ; Thu, 14 Apr 2016 09:35:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date:message-id:subject :from:to:cc; bh=X4mnCo8u+genHn7zWz3L8IbdGs6kRsAmWAq2oFPFZOs=; b=kxzCNV46fg5oU/19sJUH/6idcOmNcfEobxwaJTS4TjKdyCz7scuHBdsmI5YDQ/c+U/ edBQzS6vw3oSyEIekVNjxh+M+o7lKFMLae4lidMTUA0GwVH2xDAP5cWn9jQX3pZgkStj 4hXKXBRKR2LIUWyoTTW3PLGd/J/MKx6RdBoxJNb9k45ZGuAMpOHoEY2/haoQHcWRXOox 3lWD6c26JbDP1jf6wr9f8cdy6IKp/ZzW/vQRDYJDEKHpTiFBL9ttUltPcxNb25lIJkyt 203PYTYcX2ucs+VJvXCh3ox1SHijAJ/KmEfNgdW4CC5meTHIAiPcEYceqWmH7E29jtpV vytg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:sender:in-reply-to:references:date :message-id:subject:from:to:cc; bh=X4mnCo8u+genHn7zWz3L8IbdGs6kRsAmWAq2oFPFZOs=; b=MBZ/e4j3FdQxpv8rOHNQjU8kHEZhJhreFs35+jOCZjyFCbUOK+2C3U7L/V0/E4R1oC fqVb0mXvgE6QjyiVrG3WBYcq8WQusTOt5XxO/+Dt1mu4kvdNmykHrj7KkbpOGm1bbDXU wAPztacAIEDb85WVv/BX0d5AnHh05PBYAkSzEkmQqIXjYqZDM85W7JeS/hl6TbqzZx/R sXUYMSaUOq8CaGLPHQqECuPkESDwhVvkOnyKn1YV1Yo9pf+UcXYVgwu8ziuVC5FQJs9P MlHqHRIeOc8ISyHg2wh8KtQt5eWMYXlBRO0ofNmKsPh95mLt9tEqothrzq7Y8C9fqB76 US5g== X-Gm-Message-State: AOPr4FWabTVPOJJu3vhd3d4IEpnLpnCvlZcA0NQu4m9OEPMNnG2w7XbOgbmgJUWkZfmhVPuLUtzMu8NEVmm/Hg== MIME-Version: 1.0 X-Received: by 10.98.20.150 with SMTP id 144mr20567806pfu.144.1460651745047; Thu, 14 Apr 2016 09:35:45 -0700 (PDT) Sender: morrison.levi@gmail.com Received: by 10.66.163.232 with HTTP; Thu, 14 Apr 2016 09:35:44 -0700 (PDT) In-Reply-To: References: Date: Thu, 14 Apr 2016 10:35:44 -0600 X-Google-Sender-Auth: Rnn2uZpIQRBmxOvCtRBL-Naz9NI Message-ID: To: Tom Worster Cc: php-internals Content-Type: text/plain; charset=UTF-8 Subject: Re: [PHP-DEV] [RFC] Nullable Return Type Declaration From: levim@php.net (Levi Morrison) On Thu, Apr 14, 2016 at 9:39 AM, Tom Worster wrote: > I would like to introduce for discussion an RFC proposing and arguing for > Nullable Return Type Declaration in 7.1 and deferring for now more general > relaxations of 7.0 type as proposed in Levi's two RFCs. > > https://wiki.php.net/rfc/nullable_returns > > If anyone would like to collaborate on the RFC, I have a repo you may fork: > https://gist.github.com/tom--/e95a10fbe4d34f8a72c9 (although guthub's > formatting isn't lovely). I'm looking for help with implementation. > > Tom > > > I can appreciate that you want only the restricted union with null. However, I do not see the point of disallowing it for parameter types while allowing it for return types: function setLeft(Node $n = null) { $this->left = $n; $this->updateHeight(); } Why disallow the explicit union with null here instead of the default parameter which does not exactly capture the desired semantics? Calling `$node->setLeft()` is just odd, almost as if it was a mistake. I would much prefer `$node->setLeft(null)` here. Basically, if we have a feature for return types that exactly matches the semantics that we occasionally want for the parameter types why forbid it? Additionally, on occasion I'll see functions like this: function foo(Bar $b = null, $not_optional_param); Why not allow nullable types on parameters to avoid that wonkiness caused by default values of null? function foo(Bar | Null $b, $not_optional_param); This is much better.