Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:92320 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 89881 invoked from network); 14 Apr 2016 21:46:59 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 14 Apr 2016 21:46:59 -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.196 as permitted sender) X-PHP-List-Original-Sender: morrison.levi@gmail.com X-Host-Fingerprint: 209.85.192.196 mail-pf0-f196.google.com Received: from [209.85.192.196] ([209.85.192.196:36320] helo=mail-pf0-f196.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id F6/84-64966-2DF00175 for ; Thu, 14 Apr 2016 17:46:59 -0400 Received: by mail-pf0-f196.google.com with SMTP id p185so3890756pfb.3 for ; Thu, 14 Apr 2016 14:46:58 -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=C25ho5K6vkxV6Z5yvULwLcBC1bNHue6QSCxZtuXBqnk=; b=e+sCkNaHJehzFv4keVtCCcL4DMbr1wTlpsRM4g6Oi3vuLluA6E0W99CUbR0h9QEucy ong0g8cKYEIqVtWFiVyE4NpDo6Z4JKEia9ZTBGdrDNU4nhj7cGCC9USzGYuonhXYLLaI NrLy8S9u+CR+8htQzqpKdj1Ydaibmt/rPfO1ycGJYJsG7x5F7UHIKDaFX3zqVirlfsGI JDagS69iUvqFQnqiHcwkeCTAgG0DLUKGQCanitf5AQ3gn89Zrm1YK7r4N4GJnNSIlo/8 hb5J9NGqOitdaHuJM8cq8/JsqVw8zJ+vE4h+1XqI/1y86yFoDFh6OpmMPtA26OjA8glI JYDw== 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=C25ho5K6vkxV6Z5yvULwLcBC1bNHue6QSCxZtuXBqnk=; b=gcu7LS7mViJYwad9tk/miMRtmUzFuE3u4fq7DsOuMNZoY0DGqvud02cBXSPkb66/2w 0Kj6JwjNZNDPgKMmg05GcT37PLzwygiLUjUXeFo2m8iGuojPq+1FVQmvKGqxPixkCyYY 7aDzigJTEXBmqQcH5WSTqESzx2EBwGVBa2jh1Zqxmdvr17Y01msh3lb8hwE8crywItQc Rp6+490XWz7UNgjKFDXviKkFjfYLL8JjhnABQwcKRcD1BLTpS2YsMUVVyDatBrK3OClO fO+1roqdnWKDqf7in1GminKr1qQpkp3UYY6Bg+jozeYycJXJopJrLE4hTMc9ZmGpabW4 USTw== X-Gm-Message-State: AOPr4FWnJadNr86OM4i/rQEuNnD1jy9HGBzH45eUb/dZ5Hyp4EE/MbNAsqJGRlpBn+HGu1pa0Q+S2QV1kva1Bg== MIME-Version: 1.0 X-Received: by 10.98.26.14 with SMTP id a14mr2341771pfa.155.1460670416336; Thu, 14 Apr 2016 14:46:56 -0700 (PDT) Sender: morrison.levi@gmail.com Received: by 10.66.163.232 with HTTP; Thu, 14 Apr 2016 14:46:56 -0700 (PDT) In-Reply-To: References: Date: Thu, 14 Apr 2016 15:46:56 -0600 X-Google-Sender-Auth: PCPd81kqgos2HH5MqjLrEG6LmdU 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) >>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. > > Yes but still a code smell to me. I'd need to know more about the > programmer's intent for `foo(null, "value")`. It might be better to swap > order, or change the method name, or add another method... Who knows? Need > to take each case individually. Having a separate method instead of `foo(null, "value")` makes it difficult to use for the result of a function. Assume `bar()` returns `Bar | Null`; this would no longer work if they were separated: foo(bar(), "value") Functions are often composed so if something is the output of one function it will likely be the input to another. Thus if returning optionally null values is important to you so should optionally null parameters.