Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:82699 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 60814 invoked from network); 14 Feb 2015 20:53:57 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 14 Feb 2015 20:53:57 -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.216.49 as permitted sender) X-PHP-List-Original-Sender: smalyshev@gmail.com X-Host-Fingerprint: 209.85.216.49 mail-qa0-f49.google.com Received: from [209.85.216.49] ([209.85.216.49:65461] helo=mail-qa0-f49.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id DD/03-41866-1E5BFD45 for ; Sat, 14 Feb 2015 15:53:56 -0500 Received: by mail-qa0-f49.google.com with SMTP id w8so11718826qac.8 for ; Sat, 14 Feb 2015 12:53:51 -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=oyyQn+MqNtpWI/GOd76/9ME+VHcjoH+ENlomFmcvgcs=; b=KKqAhEif/Z4R5ejrlVBg0o/uvejsxF5qZN11+UKM4MEBK0SxqFhUXf2H4ZSJxHaX6N 5B/VJ95I0haI40T2Vfk3K1Sqs6uGyvf0VfE5+X0pmd/nw1uTbvqmM5St1QLzk6qUrRYA 6v422rG25TBAxTV7JePTVGkVy4JjjHHMw5hho+2iXUYiOXy/l68hDqm1cAEJ81Bw0HlK GqQg4gWyw5XNFqjk5thEUHw5oUbnKxt5OWlNWshH0mInej2gb0FgNMUEfoAJXBPFcJn4 FfQxzlTvgTbT6RFQB3nJPDk4quC6dy8pRQT1dhxeTmwnlSNYa3bkj3mArkimxcV85tHN 6hUA== X-Received: by 10.140.95.179 with SMTP id i48mr39433285qge.4.1423947231410; Sat, 14 Feb 2015 12:53:51 -0800 (PST) Received: from Stas-Air.local ([199.168.151.108]) by mx.google.com with ESMTPSA id j1sm7144912qas.33.2015.02.14.12.53.45 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 14 Feb 2015 12:53:50 -0800 (PST) Message-ID: <54DFB5D2.9030709@gmail.com> Date: Sat, 14 Feb 2015 15:53:38 -0500 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: Nikita Popov CC: Andrea Faulds , PHP Internals References: <680FB44D-B42D-4898-A28B-FA1C6E4D4D1A@ajf.me> <54DEE32B.6040706@gmail.com> <54DF5B79.6050009@gmail.com> In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] [RFC] Void Return Type From: smalyshev@gmail.com (Stanislav Malyshev) Hi! > One of the primary purposes of having typehints *is* documentation. This Documentation causing fatal errors is something quite unusual. And wrong. > applies both to our existing type annotations, to the newly introduced That is not true, for existing types documentation is not the only and not the primary purpose. Primary purpose is ensuring the method gets the value it expects. Otherwise phpdoc would be enough. > return declarations - and to the void return type. The advantage of > having the type declaration be part of the language (rather than a > docblock) is brevity on one hand and verification of its correctness on > the other hand. It's easy to forget to update docblock type annotations There's absolutely no brevity advantage and verification, as I mentioned, in this case is not very useful. > The void return type is actually the one case where we can at > compile-time fully verify that it is used correctly - which is great. No, you can not, since you have no idea how your function is used and where. > Allowing to return a value from a void function doesn't make sense. If Having language-enforced concept of "void function" in PHP doesn't make sense. PHP functions always return values, and verifying that function pretends to not return value has no use, as no code can depend on it. > you want to return a value, don't declare it as void. If you declare it > as void, don't return a value. It's really as simple as that. That's exactly kind of thing that makes me sad. Inviting rules in the language that exist for their own sake and then saying "well, you don't like it, don't break the rules!" -- Stas Malyshev smalyshev@gmail.com