Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:57038 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 86807 invoked from network); 22 Dec 2011 23:08:30 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 22 Dec 2011 23:08:30 -0000 Authentication-Results: pb1.pair.com smtp.mail=will.fitch@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=will.fitch@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.215.170 as permitted sender) X-PHP-List-Original-Sender: will.fitch@gmail.com X-Host-Fingerprint: 209.85.215.170 mail-ey0-f170.google.com Received: from [209.85.215.170] ([209.85.215.170:45627] helo=mail-ey0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 1A/C5-12618-D68B3FE4 for ; Thu, 22 Dec 2011 18:08:30 -0500 Received: by eaai11 with SMTP id i11so8182278eaa.29 for ; Thu, 22 Dec 2011 15:08:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=references:from:in-reply-to:mime-version:date:message-id:subject:to :cc:content-type:content-transfer-encoding; bh=UT2SPbARSYzuHSXZr8Vjyvd19QXyrRzY+kjmDc/1JuY=; b=QbYllr5lb3kyXwY1TlXpYhncKwgD6fl0UWQxge7x/zOjgYEnlzqdWu4YueX75upep8 +nqaA0gFGD7OVin0eL/A4sr3tvqnlSajc3C4D0lTCpE+XPbZjYObpX9C5CExn5Jy2HAy FMDdDof/YXMmipoFSHHGUs+kuoYwHXIQFcuqs= Received: by 10.205.127.12 with SMTP id gy12mr3807385bkc.108.1324595306503; Thu, 22 Dec 2011 15:08:26 -0800 (PST) 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> In-Reply-To: <4EF3B56A.4040809@gmail.com> Mime-Version: 1.0 (1.0) Date: Thu, 22 Dec 2011 18:08:26 -0500 Message-ID: <-2451498990672032588@unknownmsgid> To: =?UTF-8?B?w4FuZ2VsIEdvbnrDoWxleg==?= Cc: PHP Developers Mailing List Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] Return Type Hinting for Methods RFC From: will.fitch@gmail.com (Will Fitch) Sent from my iPad On Dec 22, 2011, at 5:51 PM, "=C3=81ngel Gonz=C3=A1lez" = wrote: > 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? 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. > > 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). 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. >