Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:82718 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 21441 invoked from network); 15 Feb 2015 10:31:32 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 15 Feb 2015 10:31:32 -0000 Authentication-Results: pb1.pair.com smtp.mail=francois@php.net; spf=unknown; sender-id=unknown Authentication-Results: pb1.pair.com header.from=francois@php.net; sender-id=unknown Received-SPF: unknown (pb1.pair.com: domain php.net does not designate 212.27.42.2 as permitted sender) X-PHP-List-Original-Sender: francois@php.net X-Host-Fingerprint: 212.27.42.2 smtp2-g21.free.fr Received: from [212.27.42.2] ([212.27.42.2:38919] helo=smtp2-g21.free.fr) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 47/A1-06835-38570E45 for ; Sun, 15 Feb 2015 05:31:32 -0500 Received: from moorea (unknown [82.240.16.115]) by smtp2-g21.free.fr (Postfix) with ESMTP id 5447C4B024D; Sun, 15 Feb 2015 11:31:18 +0100 (CET) Reply-To: To: "'Andrea Faulds'" , "'Xinchen Hui'" Cc: "'PHP Internals'" References: <680FB44D-B42D-4898-A28B-FA1C6E4D4D1A@ajf.me> <58F62ED2-562E-4851-B2FB-2D973732D9DA@ajf.me> In-Reply-To: Date: Sun, 15 Feb 2015 11:31:28 +0100 Message-ID: <003401d0490a$8eb7b890$ac2729b0$@php.net> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable X-Mailer: Microsoft Outlook 14.0 Thread-Index: AQJarA5HcqMrZRaN+23HbEjTjl9TGQJO6ZrBAtDhoh6bs7drgIAABr4g Content-Language: fr X-Antivirus: avast! (VPS 150215-0, 15/02/2015), Outbound message X-Antivirus-Status: Clean Subject: RE: [PHP-DEV] [RFC] Void Return Type From: francois@php.net (=?iso-8859-1?Q?Fran=E7ois_Laupretre?=) Sorry, I forgot that replacing 'void' with 'null' should support 'return null;' of course. If we don't really enforce 'void', distinguishing this from 'return;' is inconsistent, IMO. > -----Message d'origine----- > De=A0: Fran=E7ois Laupretre [mailto:francois@php.net] > Envoy=E9=A0: dimanche 15 f=E9vrier 2015 11:29 > =C0=A0: 'Andrea Faulds'; 'Xinchen Hui' > Cc=A0: 'PHP Internals' > Objet=A0: RE: [PHP-DEV] [RFC] Void Return Type >=20 > Hi, >=20 > > De=A0: Andrea Faulds [mailto:ajf@ajf.me] > > > following codes still works: > > > > > > $b =3D a(); > > > > > > so, if you want a void return type, and if you want it to be a = useful > feature.. > > > > > > above expr should be invalid with an error " a() return nothing" > > > > I'm not sure about this. PHP has always made functions valid = rvalues, for > > better or for worse. This RFC could make void functions "truly" void >=20 > What about renaming this hint to 'null', instead of 'void'. I know = that it > supports no explicit return and 'return;' with no value but what it = does is > more checking that return value is null, than checking return value is 'void', > whose concept is not defined yet. >=20 > It would remove the ambiguity on the fact that the return value is = used or > not. The only justification is that, in PHP, not returning an explicit value, or > using 'return;' returns null, that's history, period. >=20 > I think it would make the concept easier to understand and would = reserve > the ambiguous 'void' keyword for the future, if it finds a utility one day. >=20 > Cheers >=20 > Fran=E7ois