Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:37084 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 11897 invoked from network); 17 Apr 2008 16:57:30 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 17 Apr 2008 16:57:30 -0000 Authentication-Results: pb1.pair.com smtp.mail=stas@zend.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=stas@zend.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain zend.com designates 212.25.124.162 as permitted sender) X-PHP-List-Original-Sender: stas@zend.com X-Host-Fingerprint: 212.25.124.162 mail.zend.com Windows 2000 SP4, XP SP1 Received: from [212.25.124.162] ([212.25.124.162:34132] helo=mx1.zend.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 43/F6-05127-F6187084 for ; Thu, 17 Apr 2008 12:57:24 -0400 Received: from us-ex1.zend.com ([192.168.16.5]) by mx1.zend.com with Microsoft SMTPSVC(6.0.3790.3959); Thu, 17 Apr 2008 19:58:02 +0300 Received: from [192.168.16.217] ([192.168.16.217]) by us-ex1.zend.com with Microsoft SMTPSVC(6.0.3790.3959); Thu, 17 Apr 2008 09:57:58 -0700 Message-ID: <48078168.1070801@zend.com> Date: Thu, 17 Apr 2008 09:57:12 -0700 Organization: Zend Technologies User-Agent: Thunderbird 2.0.0.12 (Windows/20080213) MIME-Version: 1.0 To: Chris Stockton CC: Felipe Pena , internals@lists.php.net References: <46ccd1ab0804170742g142ed562t4f03339da549a820@mail.gmail.com> <48077BD2.2000107@zend.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 17 Apr 2008 16:57:58.0895 (UTC) FILETIME=[3085BFF0:01C8A0AC] Subject: Re: [PHP-DEV] [RFC] Strict type hints (parameter and return value) From: stas@zend.com (Stanislav Malyshev) Hi! > So: > function foo($var) { if(!is_int($var)) { throw new exception('not int'); }} What's the use of such code? If $var is '1' and not 1, what's the use of throwing an exception and having to handle it later (basically by failing the task, since you don't know how to do foo() now) - instead of just doing with that 1 what was intended for? There's no any difference between 1 and '1' that can be important to anybody. Only difference is the way it is represented in underlying bits in zvals, about which nobody should ever care. That's like making function that would accept only arguments that has 3'rd bit of pointer set to 1 and 5th bit set to 0, and reject all others. No sane application should ever behave this way. Writing such function is just plain wrong, it replaces the substance of programming with nitpicking over the details that are not important. Whole phenomenon of dynamic languages has grown on the principle of liberating people from caring for bits and concentrate on substance, and now you try to drag the bits back in. > which is called like this in both cases, maybe with a try catch etc etc: > foo((int) $baz['bar']); So every time you call foo you need try/catch? And that's supposed to be _good_? -- Stanislav Malyshev, Zend Software Architect stas@zend.com http://www.zend.com/ (408)253-8829 MSN: stas@zend.com