Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:37855 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 60177 invoked from network); 25 May 2008 08:38:27 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 25 May 2008 08:38:27 -0000 Authentication-Results: pb1.pair.com header.from=helly@php.net; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=helly@php.net; spf=unknown; sender-id=unknown Received-SPF: unknown (pb1.pair.com: domain php.net does not designate 85.214.94.56 as permitted sender) X-PHP-List-Original-Sender: helly@php.net X-Host-Fingerprint: 85.214.94.56 aixcept.net Linux 2.6 Received: from [85.214.94.56] ([85.214.94.56:35559] helo=h1149922.serverkompetenz.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 87/C4-21001-28529384 for ; Sun, 25 May 2008 04:38:26 -0400 Received: from MBOERGER-ZRH.corp.google.com (228-188.78-83.cust.bluewin.ch [83.78.188.228]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by h1149922.serverkompetenz.net (Postfix) with ESMTP id 6476011F287; Sun, 25 May 2008 10:38:23 +0200 (CEST) Date: Sun, 25 May 2008 10:37:52 +0200 Reply-To: Marcus Boerger X-Priority: 3 (Normal) Message-ID: <496536410.20080525103752@marcus-boerger.de> To: Stanislav Malyshev CC: Chris Stockton , Felipe Pena , In-Reply-To: <48078168.1070801@zend.com> References: <46ccd1ab0804170742g142ed562t4f03339da549a820@mail.gmail.com> <48077BD2.2000107@zend.com> <48078168.1070801@zend.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Subject: Re: [PHP-DEV] [RFC] Strict type hints (parameter and return value) From: helly@php.net (Marcus Boerger) Hello Stanislav, Thursday, April 17, 2008, 6:57:12 PM, you wrote: > 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 as this seems to be your only argument throughout the discussion, I suggest we implement is_numeric() and alike or allow a second parameter that to 'is_*($vaue, $strict=true)' that allows to switch to non strict mocde. We then could easily allow 'numeric' as another type hint. Or in other words I see this as a completely separate discussion. There are two discussions: a) do we want native type hints b) do we want an easy ability to deal with compatible types in type hinting marcus > 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 Best regards, Marcus