Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:88794 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 33623 invoked from network); 14 Oct 2015 22:23:20 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 14 Oct 2015 22:23:20 -0000 X-Host-Fingerprint: 2.123.167.169 unknown Received: from [2.123.167.169] ([2.123.167.169:1031] helo=localhost.localdomain) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id FF/14-33697-7D5DE165 for ; Wed, 14 Oct 2015 18:23:19 -0400 To: internals@lists.php.net References: <0A.C2.33697.6AECE165@pb1.pair.com> <561ED07E.4060809@gmail.com> Cc: Stanislav Malyshev Message-ID: <561ED5D3.1070500@ajf.me> Date: Wed, 14 Oct 2015 23:23:15 +0100 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:41.0) Gecko/20100101 Firefox/41.0 SeaMonkey/2.38 MIME-Version: 1.0 In-Reply-To: <561ED07E.4060809@gmail.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Posted-By: 2.123.167.169 Subject: =?UTF-8?Q?Re:_[PHP-DEV]_[RFC]_Void_Return_Type_=28v0.2=2c_re=c3=b6p?= =?UTF-8?Q?ening=29?= From: ajf@ajf.me (Andrea Faulds) Hi Stas, Stanislav Malyshev wrote: > > I still see no point in this, as every PHP function actually returns > something (at least null). So this type would not actually be right and > would not reflect what actually is happening. It wouldn't be incorrect. Not all languages with `void` prevent a function's use as an expression (or 'rvalue' in C parlance). In some, it merely requires the function not to explicitly return a value. And, heck, we use void in the PHP manual all the time. > Moreover, I don't see any scenario where some code depends on a function > not returning something explicitly (i.e. does not use return value) but > function actually returns something explicitly and the calling code > breaks. This appears to be impossible, It most likely is, but it's not the only case that matters. What if you mistakenly return a value in a function that's not supposed to? This would catch you out. > and thus there's no reason to > declare a function "void" except purely for documentation purposes. > Adding keywords to the language just to document this does not look to > me like a good idea. I feel that the basic facts about a function should be in the signature, and shouldn't have to be hidden in a comment, if only because it's more concicse and keeps information about parameters on the same line as the parameters themselves. Unlike comments, type hints can't lie, because they're actually enforced. But, yes, it is mostly just useful for documentation. I can understand your objection there. Thanks. -- Andrea Faulds http://ajf.me/