Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:82703 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 68189 invoked from network); 14 Feb 2015 21:37:49 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 14 Feb 2015 21:37:49 -0000 Authentication-Results: pb1.pair.com smtp.mail=ajf@ajf.me; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=ajf@ajf.me; sender-id=pass Received-SPF: pass (pb1.pair.com: domain ajf.me designates 192.64.116.199 as permitted sender) X-PHP-List-Original-Sender: ajf@ajf.me X-Host-Fingerprint: 192.64.116.199 imap11-2.ox.privateemail.com Received: from [192.64.116.199] ([192.64.116.199:52726] helo=imap11-2.ox.privateemail.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 79/50-00421-B20CFD45 for ; Sat, 14 Feb 2015 16:37:49 -0500 Received: from localhost (localhost [127.0.0.1]) by mail.privateemail.com (Postfix) with ESMTP id F22B88800D2; Sat, 14 Feb 2015 16:37:44 -0500 (EST) X-Virus-Scanned: Debian amavisd-new at imap11.ox.privateemail.com Received: from mail.privateemail.com ([127.0.0.1]) by localhost (imap11.ox.privateemail.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id yAqqgPuLmEMe; Sat, 14 Feb 2015 16:37:44 -0500 (EST) Received: from oa-res-26-240.wireless.abdn.ac.uk (oa-res-26-240.wireless.abdn.ac.uk [137.50.26.240]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.privateemail.com (Postfix) with ESMTPSA id 37C088800A2; Sat, 14 Feb 2015 16:37:43 -0500 (EST) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 8.2 \(2070.6\)) In-Reply-To: <006701d0489c$86a12470$93e36d50$@tutteli.ch> Date: Sat, 14 Feb 2015 21:37:41 +0000 Cc: PHP Internals Content-Transfer-Encoding: quoted-printable Message-ID: References: <680FB44D-B42D-4898-A28B-FA1C6E4D4D1A@ajf.me> <006701d0489c$86a12470$93e36d50$@tutteli.ch> To: Robert Stoll X-Mailer: Apple Mail (2.2070.6) Subject: Re: [PHP-DEV] [RFC] Void Return Type From: ajf@ajf.me (Andrea Faulds) Hi Robert, > On 14 Feb 2015, at 21:23, Robert Stoll wrote: >=20 > I think a void type for PHP would make sense but only if the return = value of such a function cannot be used. Why? If the return value cannot be used, it prevents the function being = used with any API that stores the return value of a callback. That=E2=80=99= s not terribly nice. A void return value doesn=E2=80=99t need to enforce anything on the = caller. PHP has always filled in missing values with NULLs, including = return values, like other dynamic languages do here. > Otherwise it is another reason for people to laugh at PHP and = justifiably so, telling that a function does not return anything but = return null is very inconsistent. It does implicitly return NULL, but NULL is a useless value, and it=E2=80=99= s returned implicitly, rather than explicitly. I don=E2=80=99t think = it=E2=80=99s really that ludicrous. > I suggest to use one of the following behaviours: > 1. declaring a function void does not return anything (hence is like = echo to a certain agree) That makes it cease to be a function in the PHP sense. PHP always allows = functions to be used in expressions. > 2. declaring a function void does return a thing of type void (that = would be similar to Unit in scala) We don=E2=80=99t need another form of NULL. Also, a thing of type void could be passed around, just as the unit type = can be in other languages, so it wouldn=E2=80=99t do what you want it = to. > 3. instead of void a function can be declared to be of type null -> = almost the same behaviour as your RFC but without the inconsistency That seems like a strange solution. You=E2=80=99re requiring the = function to always return a useless value. -- Andrea Faulds http://ajf.me/