Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:88812 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 4005 invoked from network); 15 Oct 2015 10:17:20 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 15 Oct 2015 10:17:20 -0000 Authentication-Results: pb1.pair.com smtp.mail=rowan.collins@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=rowan.collins@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.212.170 as permitted sender) X-PHP-List-Original-Sender: rowan.collins@gmail.com X-Host-Fingerprint: 209.85.212.170 mail-wi0-f170.google.com Received: from [209.85.212.170] ([209.85.212.170:34102] helo=mail-wi0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 17/42-23021-E2D7F165 for ; Thu, 15 Oct 2015 06:17:18 -0400 Received: by wicgb1 with SMTP id gb1so21231625wic.1 for ; Thu, 15 Oct 2015 03:17:14 -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:content-transfer-encoding; bh=z1Z2mEqM1pYgYdgkOrU6LlS6bDkyAKtc+bVenD3Wpv0=; b=LtEYslt0XwrcA16ZptGUwbudKTCGsHXgA0XjeZM9Ykz2YcD0q0eptzVudGmZQuD/j1 ++zJSUp57MpyTXDq6GRUK4KRqLSQZkX5j5ezUovFoZiQhudMOzWwwL7vOu0M5aDdKogW W15TTH2akkqQjHdbv0RyOcgt1d1SlyX0OXT9hokI4/xC0nCffKa4AaQvkN8DDHwHVFwl CwxXQ76tsHEcn8nC2nUHoAurU0cak8qf0PBmDh1LTvGSX2LOkG3idIJgy96Ihq0ihNQP 6gFr7EJlYMzxQk30Lc3ruh6nPbnKmSFGGCM9vvCInGp0Jo9HQ9FGh4gOtGmkb5j1rs4h j/mQ== X-Received: by 10.194.216.34 with SMTP id on2mr10429370wjc.18.1444904234306; Thu, 15 Oct 2015 03:17:14 -0700 (PDT) Received: from [192.168.0.132] ([93.188.182.58]) by smtp.googlemail.com with ESMTPSA id gc14sm10808330wic.12.2015.10.15.03.17.13 for (version=TLSv1/SSLv3 cipher=OTHER); Thu, 15 Oct 2015 03:17:13 -0700 (PDT) To: internals@lists.php.net References: <0A.C2.33697.6AECE165@pb1.pair.com> Message-ID: <561F7D17.5050306@gmail.com> Date: Thu, 15 Oct 2015 11:16:55 +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: <0A.C2.33697.6AECE165@pb1.pair.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit 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) Andrea Faulds wrote on 14/10/2015 22:52: > Good evening, > > I'm reviving my Void Return Type RFC, this time for PHP 7.1: > > https://wiki.php.net/rfc/void_return_type > > Please read it and tell me your thoughts! My feeling is that it is odd to have both of these be true at once: - void functions can appear in expressions, where the return value is interpreted as null - "return;" and "return null;" are no longer treated as equivalent If the intent is to say "you can use this in an expression, but its value will always be null so there's no point", then "return null;" seems just as valid as "return;", and a typehint of "null" seems to make more sense. I take the point about making intent clear, but can't think of any other interpretation of "this function always returns null" than "this function has no meaningful result". In other words, I can't imagine ever wanting to use "null" to mean something different from "void" in this context. I can see the point in denying the right to say "return some_function_expected_to_return_null();" But in a sense this is no different from declaring that a function returns int, and then writing "return some_function_expected_to_return_int();" If a void function can be used in an expression, it can be used in a return expression, and if so, it feels natural for the type hint to propagate: function foo(): void { do_something(); } function wrapped_foo(): void { do_something_else(); return foo(); } // ERROR: can't specify return value in a void function "return foo()" is not illegal because foo is declared void, but because wrapped_foo is - even though the result is exactly as expected. Regards, -- Rowan Collins [IMSoP]