Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:52083 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 66887 invoked from network); 29 Apr 2011 08:55:39 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 29 Apr 2011 08:55:39 -0000 Authentication-Results: pb1.pair.com smtp.mail=addw@phcomp.co.uk; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=addw@phcomp.co.uk; sender-id=permerror 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:33989] helo=bytemark.phcomp.co.uk) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 69/A5-29189-A0D7ABD4 for ; Fri, 29 Apr 2011 04:55:39 -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 1QFjU6-00081L-10 for internals@lists.php.net; Fri, 29 Apr 2011 09:55:34 +0100 Received: from addw by mint.phcomp.co.uk with local (Exim 4.63) (envelope-from ) id 1QFjU5-0003oH-Ge for internals@lists.php.net; Fri, 29 Apr 2011 09:55:33 +0100 Date: Fri, 29 Apr 2011 09:55:33 +0100 To: internals Message-ID: <20110429085533.GF8496@phcomp.co.uk> Mail-Followup-To: internals References: <4DB923E6.3020307@sugarcrm.com> <4DB9A7BE.6010307@sugarcrm.com> <20110428181630.GA8496@phcomp.co.uk> <4DBA46FD.5090106@sugarcrm.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4DBA46FD.5090106@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:05:01PM -0700, Stas Malyshev wrote: > Hi! > > >I will accept that sometimes it must always be done run time, eg: > > > > $funcName($arg) > > > >but that still allows most calls at compile time. > > This is not the issue. This is the issue: $foo->bar($arg). > There's no way to resolve it in "compile time", whatever that means, > without having a type on $foo. Which a good compiler with time to burn (think HipHop not Zend) could do, eg: function joe(SomeClass $foo) or: $foo = new SomeClass(); or: function SomeClass fred() { ... } ... $foo = fred(); > >Anyway - the check for return type would be done in the called function, > >not the calling function. > > That's the point. You don't get any extra safety on the caller's side, > because you don't actually know much about the called function. With You could by resolving the 'requires' at compile time, most of which you can. Yes you can find some examples when it won't, but don't ignore the most for the sake of a few. > You are talking about pretty big change in language nature - introducing > strict typing. "It's just option, don't use it if you don't want" > doesn't really sound good in this case. If it's in the language, it > should make sense and sit well with the rest of the language. And it will. Objects are a big thing in the language - but their use is not mandated, many programs don't use them. -- 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