Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:88823 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 36851 invoked from network); 15 Oct 2015 16:22:09 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 15 Oct 2015 16:22:09 -0000 Authentication-Results: pb1.pair.com header.from=rowan.collins@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=rowan.collins@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.215.46 as permitted sender) X-PHP-List-Original-Sender: rowan.collins@gmail.com X-Host-Fingerprint: 209.85.215.46 mail-lf0-f46.google.com Received: from [209.85.215.46] ([209.85.215.46:33230] helo=mail-lf0-f46.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id A5/A7-23021-4A2DF165 for ; Thu, 15 Oct 2015 12:22:01 -0400 Received: by lffv3 with SMTP id v3so35148618lff.0 for ; Thu, 15 Oct 2015 09:21:47 -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-type; bh=5N165rBougB3JdnYHiBbOi+unKIvi67DiFILKxt7q50=; b=Z7bvSUwYDPFtAai3c7oDJCqoxhYe29tGoL8G8OFDR4eqBOeuoriwpO+gkWR4zxDowZ kKZ7A4OSZIch64WZwNaLlv4YVh6XS3RRyRBjTx/iJ6dlB/HIJ2A48e8RH+ftc9sNwdOT b1hIgOxeA4W0dM+/pRjO6ZA2yvCA/9NkSEjrl/G/WL98m0m9wazVKyXGa/Ewi/nABLTU xhskgSA9D0t108pmALz4ux+WwOFmRWvU7BFOXi/V79n+0SV3YxKns1m3tNqK6zrQpfwe jDBJdZOY6+D5wPzvFgRd8+vdWLeyUiGQ2EePnrzD3xHn1NIo1nHL4qL97qPJtCcMg1RM Ha+w== X-Received: by 10.180.99.41 with SMTP id en9mr4179637wib.67.1444926107777; Thu, 15 Oct 2015 09:21:47 -0700 (PDT) Received: from [192.168.0.132] ([93.188.182.58]) by smtp.googlemail.com with ESMTPSA id uq5sm17347526wjc.3.2015.10.15.09.21.46 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 15 Oct 2015 09:21:47 -0700 (PDT) To: internals@lists.php.net References: <0A.C2.33697.6AECE165@pb1.pair.com> <561F7D17.5050306@gmail.com> <561FCD9F.10104@gmail.com> Message-ID: <561FD288.5080503@gmail.com> Date: Thu, 15 Oct 2015 17:21:28 +0100 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/alternative; boundary="------------070600080207010706060308" Subject: =?UTF-8?Q?Re:_[PHP-DEV]_[RFC]_Void_Return_Type_=28v0.2=2c_re=c3=b6p?= =?UTF-8?Q?ening=29?= From: rowan.collins@gmail.com (Rowan Collins) --------------070600080207010706060308 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Pedro Cordeiro wrote on 15/10/2015 17:14: > I've been thinking about what PHP should do when accessing the return > value of a `void` function, and so far, I think the consistent thing > should be to get NULL, while throwing an E_NOTICE. > > $a = $b; //$b wasn't initiated. > > This does the same thing. I tried accessing what was supposed to be > 'nothing' ($b), and got NULL with an E_NOTICE being thrown. > > function myFunc() : void { ... } > $a = myFunc(); > > I see no reason why this should silently assign NULL to $a, > *specially* with "return null;" being explicitly forbidden. ... The > behaviour should be consistent (NULL should be accessed, as for all > undefined things), with an E_NOTICE. I don't know how easy this would be to implement, but I agree that this would make the "void" keyword feel more meaningful. Does the Engine have a way to know whether a return value is being used or discarded for optimisation purposes? If so, could that logic be hooked to provide the Notice? Regards, -- Rowan Collins [IMSoP] --------------070600080207010706060308--