Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:57042 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 91764 invoked from network); 22 Dec 2011 23:28:52 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 22 Dec 2011 23:28:52 -0000 Authentication-Results: pb1.pair.com smtp.mail=derick@php.net; spf=unknown; sender-id=unknown Authentication-Results: pb1.pair.com header.from=derick@php.net; sender-id=unknown Received-SPF: unknown (pb1.pair.com: domain php.net does not designate 82.113.146.227 as permitted sender) X-PHP-List-Original-Sender: derick@php.net X-Host-Fingerprint: 82.113.146.227 xdebug.org Linux 2.6 Received: from [82.113.146.227] ([82.113.146.227:48896] helo=xdebug.org) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id DE/C6-12618-43DB3FE4 for ; Thu, 22 Dec 2011 18:28:52 -0500 Received: from localhost (xdebug.org [127.0.0.1]) by xdebug.org (Postfix) with ESMTPS id 65F1BDE142; Thu, 22 Dec 2011 23:28:49 +0000 (GMT) Date: Thu, 22 Dec 2011 23:28:49 +0000 (GMT) X-X-Sender: derick@whisky.home.derickrethans.nl To: Will Fitch cc: =?UTF-8?Q?=C3=81ngel_Gonz=C3=A1lez?= , PHP Developers Mailing List In-Reply-To: <-2451498990672032588@unknownmsgid> Message-ID: References: <2095305E-D4E3-4D7E-8218-32EE99688E0C@GMAIL.COM> <2C90FB94-38C4-4270-8C6A-B89304BA8ED8@gmail.com> <159A7CA2-8561-40DA-9434-CAAE12304DDB@gmail.com> <4EF3B56A.4040809@gmail.com> <-2451498990672032588@unknownmsgid> User-Agent: Alpine 2.02 (DEB 1266 2009-07-14) MIME-Version: 1.0 Content-Type: MULTIPART/MIXED; BOUNDARY="8323329-429341453-1324596529=:27751" Subject: Re: [PHP-DEV] Return Type Hinting for Methods RFC From: derick@php.net (Derick Rethans) --8323329-429341453-1324596529=:27751 Content-Type: TEXT/PLAIN; charset=UTF-8 Content-Transfer-Encoding: QUOTED-PRINTABLE On Thu, 22 Dec 2011, Will Fitch wrote: > Sent from my iPad > On Dec 22, 2011, at 5:51 PM, "=C3=81ngel Gonz=C3=A1lez" wrote: >=20 > > Your examples only show class methods with visibility qualifyiers, and > > looking at the changes to zend_language_parser.y > > it seems as if would only be available for methods. Wouldn't return > > hints be available for plain functions? >=20 > Right now, it's only available for methods. Personally, I'm not a fan > of return types for functions. Adding this for functions in its form > today will also introduce shift/reduce issues. IMO, it should work for normal functions too.=20 > > In functional programming, it is common to return nullable types: > > returns an instance of class Foo or null, an array or false, etc. > > > > This is supported in normal arguments with the "=3D null" hint, and I > > think there should be something equivalent for return types. > > Does the proposed implementation allow null everywhere? (there's an > > example of returning null from a return hint of array) > > That seems wrong to me. Unless there's a way to make it strict (eg. > > array! for only arrays). >=20 > Most modern languages allow returning null in any case. This is a hail > Mary in the event something happens, but throwing an exception is > inappropriate. I see no reason to diverge from that. I tend to agree with that one. cheers, Derick --=20 http://derickrethans.nl | http://xdebug.org Like Xdebug? Consider a donation: http://xdebug.org/donate.php twitter: @derickr and @xdebug --8323329-429341453-1324596529=:27751--