Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:52056 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 83764 invoked from network); 28 Apr 2011 13:31:01 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 28 Apr 2011 13:31:01 -0000 Authentication-Results: pb1.pair.com header.from=martinscotta@gmail.com; sender-id=pass; domainkeys=bad Authentication-Results: pb1.pair.com smtp.mail=martinscotta@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.212.42 as permitted sender) DomainKey-Status: bad X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: martinscotta@gmail.com X-Host-Fingerprint: 209.85.212.42 mail-vw0-f42.google.com Received: from [209.85.212.42] ([209.85.212.42:54700] helo=mail-vw0-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 46/69-28716-21C69BD4 for ; Thu, 28 Apr 2011 09:30:58 -0400 Received: by vwl1 with SMTP id 1so2249823vwl.29 for ; Thu, 28 Apr 2011 06:30:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:date :message-id:subject:from:to:content-type; bh=B5/MTx6REMTZZgd1Y7g3SbAPIfupfJsjTd8/So7gbiQ=; b=H3Cl5+6M9K/W+iiiaD+LEq80fQMqRQQFNeNmvW1dQSi/gKFpEm+LNVGgu33ikPdb4k zeLGiGqrJQAESk/x4rM9UiVJY+bt3/vX6iuxh5lnOIDairIBmRTdFjF/2CvC0fKDOVz4 OhEV1oW+TGHX7OffUm83fxZ8kDerarV/HDh8M= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; b=okHYYq7lVH96QyMfrKvtxkXHeblmJ774lTmQMq8Oenmeug2nZWZwQcgoWywsS4Xd9u +aqwgtJI1+JK2/EoPnpfpCosCZPzbkIdRQPC0MkMKr2oA/zrOEUpoGWLi668Kc38eyBA JHwRc+4kngHxsP+tbkauMDhiUekmjsEz0Uk6Y= MIME-Version: 1.0 Received: by 10.52.174.243 with SMTP id bv19mr514597vdc.93.1303997443561; Thu, 28 Apr 2011 06:30:43 -0700 (PDT) Received: by 10.220.189.197 with HTTP; Thu, 28 Apr 2011 06:30:43 -0700 (PDT) In-Reply-To: <20110428095958.GM8496@phcomp.co.uk> References: <4DB923E6.3020307@sugarcrm.com> <4DB925D4.5090107@thelounge.net> <4DB926B4.5000307@sugarcrm.com> <20110428085859.GJ8496@phcomp.co.uk> <4DB936C8.2080801@lerdorf.com> <20110428095958.GM8496@phcomp.co.uk> Date: Thu, 28 Apr 2011 10:30:43 -0300 Message-ID: To: Rasmus Lerdorf , Stas Malyshev , Reindl Harald , "internals@lists.php.net" Content-Type: multipart/alternative; boundary=bcaec51a8e0c695a2f04a1fa90f2 Subject: Re: [PHP-DEV] [RFC] Return type-hint From: martinscotta@gmail.com (Martin Scotta) --bcaec51a8e0c695a2f04a1fa90f2 Content-Type: text/plain; charset=ISO-8859-1 Hey All, I'm really interested on this topic. What would be the result of this? function Foo foo($something) { if ( $something ) { return new Foo; } // no return implies return null } How do you force to return a Type with null allowed? Martin Scotta On Thu, Apr 28, 2011 at 6:59 AM, Alain Williams wrote: > On Thu, Apr 28, 2011 at 02:43:36AM -0700, Rasmus Lerdorf wrote: > > > > function array foo() { .... } > > > > > > $ret = foo(); > > > foreach($ret as $val) > > > .... > > > > I don't see this being useful at all. All you are doing is duplicating a > > runtime warning. We can't possibly know at compile-time whether this > > return value is an array or not, so there is no compile-time benefit. > > The check is not done where foo() is called but within foo() itself, to > ensure > that it only returns an array. > > There will also be advantages for HipHop which can afford to spend the time > to > do static analysis of code -- I know that HipHop is not your baby > but you now need to recognise that there is more than one PHP > implementation > and features that may not had much advantage with Zend may be useful > elsewhere. > > -- > Alain Williams > Linux/GNU Consultant - Mail systems, Web sites, Networking, Programmer, IT > Lecturer. > +44 (0) 787 668 0256 http://www.phcomp.co.uk/ > Parliament Hill Computers Ltd. Registration Information: > http://www.phcomp.co.uk/contact.php > #include > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > > --bcaec51a8e0c695a2f04a1fa90f2--