Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:37066 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 12539 invoked from network); 17 Apr 2008 14:13:21 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 17 Apr 2008 14:13:21 -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=pass Received-SPF: pass (pb1.pair.com: domain phcomp.co.uk designates 213.152.38.186 as permitted sender) X-PHP-List-Original-Sender: addw@phcomp.co.uk X-Host-Fingerprint: 213.152.38.186 freshmint.phcomp.co.uk Linux 2.5 (sometimes 2.4) (4) Received: from [213.152.38.186] ([213.152.38.186:60483] helo=mint.phcomp.co.uk) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id C8/61-05127-DFA57084 for ; Thu, 17 Apr 2008 10:13:19 -0400 Received: from addw by mint.phcomp.co.uk with local (Exim 4.69) (envelope-from ) id 1JmUrR-00079s-Ba; Thu, 17 Apr 2008 15:13:13 +0100 Date: Thu, 17 Apr 2008 15:13:13 +0100 To: Sam Barrow Cc: internals@lists.php.net Message-ID: <20080417141313.GX18783@mint.phcomp.co.uk> References: <1208404255.5665.34.camel@pena> <1208440873.32403.6.camel@sbarrow-desktop> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1208440873.32403.6.camel@sbarrow-desktop> User-Agent: Mutt/1.4.1i Organization: Parliament Hill Computers Ltd Subject: Re: [PHP-DEV] [RFC] Type hints (parameter and return value) From: addw@phcomp.co.uk (Alain Williams) On Thu, Apr 17, 2008 at 10:01:13AM -0400, Sam Barrow wrote: > On Thu, 2008-04-17 at 14:52 +0200, Paul Biggar wrote: > > just the copy in the callee - I think this is a good idea). As an > > example, this will fail, which it shouldnt: function y (int $x) { > > assert (is_int($x); } y ("24"); > > The problem with this is that there's not much point in converting the > value. PHP will do that anyway, making this kind of pointless. If inside y() you have something like: for( $i = 0; $i < $x; $i++ ) you will end up converting $x to integer $x times ... which will eat CPU if $x is large -- I tried it. An: assert (is_int($x)) followed by: $x = (int)$x is the way to go. > This only serves to include an additional type juggling system into php, > which is very confusing. If you don't understand it: don't use it. -- Alain Williams Linux 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 Chairman of UKUUG: http://www.ukuug.org/ #include