Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:88819 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 30212 invoked from network); 15 Oct 2015 16:00:56 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 15 Oct 2015 16:00:56 -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.48 as permitted sender) X-PHP-List-Original-Sender: rowan.collins@gmail.com X-Host-Fingerprint: 209.85.215.48 mail-lf0-f48.google.com Received: from [209.85.215.48] ([209.85.215.48:35950] helo=mail-lf0-f48.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 8F/36-23021-7BDCF165 for ; Thu, 15 Oct 2015 12:00:56 -0400 Received: by lfeh64 with SMTP id h64so33251598lfe.3 for ; Thu, 15 Oct 2015 09:00:52 -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=G+EebUqVv0OUAwPT0XeYPDErP3jWAghoUD1HlBFOm4s=; b=A22JgBaRUs8QVlMr8WaoMYrQnm+5POOHet6adiLus9IyFg9f4moFEVyQjCObhU5ORc khrMDeq04VkStEPl8GQOX+hyWO5emCl/Xe/JGDmAWwkTMjmpKucarp8LPBMACs36BPdL od4ku50ilMowmP9ZN2FzZ5nswTMG1+kVX6uo4SyyChwJhxlkpIQOoCW4WHeBkGW3f2aK ERJSt3hPV5DfNmw9NavcH/+zxeJ3oy/gO+rBkNH6mEjuDCLN/tpEJTh/4m/t3us59tBR L68ZHEWixn5YsnltGIXbRrS24LblMeGGS3gFoN5dbxs5NE6QAeunBVjzQTjV2gT8v2KD 9tng== X-Received: by 10.180.35.163 with SMTP id i3mr37745684wij.55.1444924851206; Thu, 15 Oct 2015 09:00:51 -0700 (PDT) Received: from [192.168.0.132] ([93.188.182.58]) by smtp.googlemail.com with ESMTPSA id qc4sm17253901wjc.33.2015.10.15.09.00.50 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 15 Oct 2015 09:00:50 -0700 (PDT) To: internals@lists.php.net References: <0A.C2.33697.6AECE165@pb1.pair.com> <561F7D17.5050306@gmail.com> Message-ID: <561FCD9F.10104@gmail.com> Date: Thu, 15 Oct 2015 17:00:31 +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: 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 15/10/2015 16:32: > Hmm, this is an interesting case you've pointed out. Being able to do > `return some_other_void_function();` is something I've desired in > other languages. > > But what if that void function you're calling later adds a return > value? Now the calling function is returning a value other than null, > violating its type hint and producing a runtime error. Well, fundamentally, this is true of anything short of full type-checking. The type safety below is self-evident: function foo(): int { return 42; } function wrapped_foo(): int { return foo(); } But foo() could later be changed to this: function foo(): string { return 'The Answer'; } The wrapped_foo() typehint is now broken. That's not really any different from foo() starting off as void/returns-null and adding a return value. In both cases, a static analyser could detect the discrepancy, but the Zend Engine will not, until the function is executed. > It's a shame there's no "tail call this other function and discard its > result" construct. Yeah, I guess what you really want is for a void function to be able to "goto foo();" Regards, -- Rowan Collins [IMSoP]