Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:82686 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 20202 invoked from network); 14 Feb 2015 14:28:15 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 14 Feb 2015 14:28:15 -0000 Authentication-Results: pb1.pair.com header.from=smalyshev@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=smalyshev@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.220.51 as permitted sender) X-PHP-List-Original-Sender: smalyshev@gmail.com X-Host-Fingerprint: 209.85.220.51 mail-pa0-f51.google.com Received: from [209.85.220.51] ([209.85.220.51:54702] helo=mail-pa0-f51.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 4A/52-03565-E7B5FD45 for ; Sat, 14 Feb 2015 09:28:15 -0500 Received: by mail-pa0-f51.google.com with SMTP id eu11so25019576pac.10 for ; Sat, 14 Feb 2015 06:28:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding; bh=nuz7xNkTv7koQgqu9QCL4QrfynH3BWM8RR97mAAlXuY=; b=U8XvZa0HqOXck+i+E4L8kALfl+F2dd72lPnNkAGbIYqlpViSRS/AQGufKezHRK+n3X NXL/dea2CTVN58WiQ/Y4yFNPZ+JFZ9f7yuuRprFxwk+4N4cIHi7X8HK441Ii9ekc/duY y1Q3lGUaEms2uE0lhy0zGOEe8Fo9bG4voKUKQKanXqVlDsGtnFz0ab7y1pWzV2U95Oem ZiXOMPFxKR93RBxEVSTYWLeQ23HpQKzR0qn1OAVK1HVPnSHBy5J1Ffk18PPry4WPMd8f SV1BOGepaTtTL5d0njZfVSZTOrUQW5Y4wocz1PuBAF3KCZigZXnvBhRzHJE6RKxZRWak m8HQ== X-Received: by 10.68.185.194 with SMTP id fe2mr23623485pbc.136.1423924091183; Sat, 14 Feb 2015 06:28:11 -0800 (PST) Received: from Stas-Air.local ([216.9.110.3]) by mx.google.com with ESMTPSA id ff10sm9771036pad.1.2015.02.14.06.28.10 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 14 Feb 2015 06:28:10 -0800 (PST) Message-ID: <54DF5B79.6050009@gmail.com> Date: Sat, 14 Feb 2015 06:28:09 -0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:31.0) Gecko/20100101 Thunderbird/31.4.0 MIME-Version: 1.0 To: Andrea Faulds CC: PHP Internals References: <680FB44D-B42D-4898-A28B-FA1C6E4D4D1A@ajf.me> <54DEE32B.6040706@gmail.com> In-Reply-To: Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] [RFC] Void Return Type From: smalyshev@gmail.com (Stanislav Malyshev) Hi! > What would be the point of *allowing* returning a value? It's clearly It's an error only because you declared it an error. > an error. We could let you return anything and then discard it, but > now you won't spot the error in your code. Function return values which are going unused all the time. In PHP, functions are very frequently called for side effects and not return values. So returning value and discarding it is a common and perfectly valid scenario. And it also has absolutely nothing to do with void declaration - void declaration doesn't cause discarding the value and you can discard the value with or without it. > It's not merely for the sake of it. It makes function signatures more > descriptive, and lets you catch bugs in your code. Only bug it can catch is wrongly declaring the function to be void - which is introduced by this RFC. For me, it is a clear case of generating error for the sake of error. > We already use void in the manual: why not in PHP? Because the manual is the *documentation*, not code. It explains that the function does not return anything useful. It's not the same as creating an error when function returns something useful. -- Stas Malyshev smalyshev@gmail.com