Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:88850 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 18982 invoked from network); 16 Oct 2015 09:04:20 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 16 Oct 2015 09:04:20 -0000 Authentication-Results: pb1.pair.com smtp.mail=php@tutteli.ch; spf=fail; sender-id=fail Authentication-Results: pb1.pair.com header.from=php@tutteli.ch; sender-id=fail Received-SPF: fail (pb1.pair.com: domain tutteli.ch does not designate 80.74.154.80 as permitted sender) X-PHP-List-Original-Sender: php@tutteli.ch X-Host-Fingerprint: 80.74.154.80 hyperion2.kreativmedia.ch Linux 2.6 Received: from [80.74.154.80] ([80.74.154.80:48283] helo=hyperion2.kreativmedia.ch) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 48/25-15862-B8DB0265 for ; Fri, 16 Oct 2015 05:04:14 -0400 Received: from RoLaptop (adsl-84-226-55-217.adslplus.ch [84.226.55.217]) by hyperion2.kreativmedia.ch (Postfix) with ESMTPSA id 7463DDCE809C; Fri, 16 Oct 2015 11:04:08 +0200 (CEST) To: "'Andrea Faulds'" , References: <0A.C2.33697.6AECE165@pb1.pair.com> <11.10.09496.8F410265@pb1.pair.com> In-Reply-To: <11.10.09496.8F410265@pb1.pair.com> Date: Fri, 16 Oct 2015 11:04:07 +0200 Message-ID: <001b01d107f1$9d672370$d8356a50$@tutteli.ch> 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: AQIlm6HitWabnDu1qXRDdKGyTlYfFAGnR/Yjnbdjm3A= Content-Language: de-ch Subject: =?iso-8859-1?Q?AW:_=5BPHP-DEV=5D_Re:_=5BRFC=5D_Void_Return_Type_=28v0.2?= =?iso-8859-1?Q?=2C_re=F6pening=29?= From: php@tutteli.ch ("Robert Stoll") Hi Andrea > -----Urspr=FCngliche Nachricht----- > Von: Andrea Faulds [mailto:ajf@ajf.me] > Gesendet: Donnerstag, 15. Oktober 2015 23:04 > An: internals@lists.php.net > Betreff: [PHP-DEV] Re: [RFC] Void Return Type (v0.2, re=F6pening) >=20 > Hi everyone, >=20 > Andrea Faulds wrote: > > 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! >=20 > Since the void/null naming issue has been a frequently-asked question, = I've added a subsection to the RFC explaining why I > chose this name. It doesn't really say anything I haven't said = already, it just summarises it. In particular, it lists a bunch of > languages using `void`, some of which do what PHP does. >=20 > The new section is here: > = https://wiki.php.net/rfc/void_return_type#why_call_it_void_and_not_null >=20 > Thanks. >=20 > -- > Andrea Faulds > http://ajf.me/ >=20 > -- > PHP Internals - PHP Runtime Development Mailing List To unsubscribe, = visit: http://www.php.net/unsub.php You write in your RFC "others do allow void functions in expressions, = just as PHP does, by making them implicitly return some unit type." You mentioned TypeScript -- unit type =3D null -- ActionScript -- unit = type =3D undefined -- and Swift -- unit type =3D empty tuple, ergo (). TypeScript [1] allows to return null, ActionScript does not allow to = return undefined, and Swift allows to return an empty tuple explicitly [2]. I agree with others that is seems inconsistent to use the name void but = allow to use void functions in expression (return implicitly a unit type) and in the same time forbid to return = the unit type explicitly in such functions. IMO ActionScript should have allowed to return the unit type explicitly = as well and so should PHP. At first I did not like the idea of introducing void in PHP at all if it = has not the same behaviour as in C -- meaning it should be forbidden to use void functions in expressions -- but now I = think it better suits PHP if void stands for return nothing (hence null implicitly) or null explicitly. I think you = should change your RFC to allow returning explicitly null for two reasons: 1. Implicit and explicit behaviour should be consistent. If a function = returns null implicitly then it should be allowed to return null explicitly. 2. Not everyone might be aware of the implicit behaviour and some code = conventions might want to be explicit on this part and dictate that one needs to express the behaviour in code.=20 To conclude, personally I want that the following are all equivalent: function foo() : void {} function foo() : void { return; } function foo() : void { return null; } To go a step further, I kind of like the idea that using the return = value of a void function results (at least) in an E_NOTICE. But maybe that is something for PHP 8.=20 Another random thought, why not treat void like Void [3] in Java where = null is the only valid value of this type? Nah... bad idea, would be too heavy to use an object everywhere and secondly it = would force to write "return null;" all the time, so forget about it. [1] = http://www.typescriptlang.org/Playground#src=3Dfunction%20foo()%3Avoid%7B= return%20null%3B%7D%0A=20 [2] http://swiftstub.com/114266460/?v=3Dgm [3] http://docs.oracle.com/javase/7/docs/api/java/lang/Void.html=20