Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:52070 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 34227 invoked from network); 28 Apr 2011 18:16:38 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 28 Apr 2011 18:16:38 -0000 Authentication-Results: pb1.pair.com header.from=addw@phcomp.co.uk; sender-id=permerror Authentication-Results: pb1.pair.com smtp.mail=addw@phcomp.co.uk; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain phcomp.co.uk designates 80.68.91.63 as permitted sender) X-PHP-List-Original-Sender: addw@phcomp.co.uk X-Host-Fingerprint: 80.68.91.63 bytemark.phcomp.co.uk Received: from [80.68.91.63] ([80.68.91.63:39152] helo=bytemark.phcomp.co.uk) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 84/F0-29189-50FA9BD4 for ; Thu, 28 Apr 2011 14:16:38 -0400 Received: from freshmint.phcomp.co.uk ([78.32.209.33] helo=mint.phcomp.co.uk) by bytemark.phcomp.co.uk with esmtps (TLSv1:AES256-SHA:256) (Exim 4.71) (envelope-from ) id 1QFVlR-00037M-W9 for internals@lists.php.net; Thu, 28 Apr 2011 19:16:34 +0100 Received: from addw by mint.phcomp.co.uk with local (Exim 4.63) (envelope-from ) id 1QFVlO-0000LX-6m for internals@lists.php.net; Thu, 28 Apr 2011 19:16:30 +0100 Date: Thu, 28 Apr 2011 19:16:30 +0100 To: internals Message-ID: <20110428181630.GA8496@phcomp.co.uk> Mail-Followup-To: internals References: <4DB923E6.3020307@sugarcrm.com> <4DB9A7BE.6010307@sugarcrm.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4DB9A7BE.6010307@sugarcrm.com> User-Agent: Mutt/1.4.2.2i Organization: Parliament Hill Computers Ltd Subject: Re: [PHP-DEV] [RFC] Return type-hint From: addw@phcomp.co.uk (Alain Williams) On Thu, Apr 28, 2011 at 10:45:34AM -0700, Stas Malyshev wrote: > Hi! > > >I see many advantages of the introduction of return type hinting. > >- you can guarantee that your methods returns only what is explicitly > >stated (or else it blows up, the same as for arguments) > > You can't, because function resolution happens in runtime, so the only > point you know what the function called "foo" returns is the moment > where you're already calling it, not a moment before. The Zend engine does function resolution at run time - others (eg HipHop) can afford to do it at compile time and so will know at compile time. I will accept that sometimes it must always be done run time, eg: $funcName($arg) but that still allows most calls at compile time. Anyway - the check for return type would be done in the called function, not the calling function. > >- I think maybe the language itself could use that information, for > >performance, etc. improvements (we know that the return value will be > > That would need static compile-time binding of functions, which implies > static binding of includes, etc. - basically, compiling PHP code as a > whole in one monolitic application. Which might be acceptable for some applications. For those where it is not then this feature may not be useful. This is an *optional* declaration, not mandatory - so if it does not suit your purpose -- don't use it. -- 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