Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:44889 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 10046 invoked from network); 10 Jul 2009 03:02:31 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 10 Jul 2009 03:02:31 -0000 Authentication-Results: pb1.pair.com header.from=johncogg@gmail.com; sender-id=pass; domainkeys=bad Authentication-Results: pb1.pair.com smtp.mail=johncogg@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.217.214 as permitted sender) DomainKey-Status: bad X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: johncogg@gmail.com X-Host-Fingerprint: 209.85.217.214 mail-gx0-f214.google.com Received: from [209.85.217.214] ([209.85.217.214:52800] helo=mail-gx0-f214.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id AC/34-23850-54FA65A4 for ; Thu, 09 Jul 2009 23:02:30 -0400 Received: by gxk10 with SMTP id 10so1042393gxk.23 for ; Thu, 09 Jul 2009 20:02:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:sender:received:in-reply-to :references:date:x-google-sender-auth:message-id:subject:from:to :content-type:content-transfer-encoding; bh=17VDTO1rTwb5fsvp+/+FnshSCYAKftu7B4TC+O9Uph8=; b=SSMyTXHQsGqfciCJPfaCCoumHw7DYq5FxJoTSW9replkbz447W7rqTpBWK+xBf/62F 0SGMgGFCCt3jukezve9Ch8xIVrYoIafLX2+9QwWFN5vokNRTAGUKapWesOn64PGeiYCn qJD80zeheIWUav9S+Jv6U6PVkqjzV8eNfVqrA= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:content-type :content-transfer-encoding; b=LsYr5wOfY87z0rAx5+3NNyGNs2cI1qH77afSo9K7EO/vktHyzTpTLH4TXuzU6EMKUJ v2l6K7lfwVbZx2obER2KzQIBfhbXWQB393iqAbNmzqUGk/d9WBqJIXrLL8FS+H30x96C afza7RKK1NNx4AVoPwHtWwSrNHrNAGBXmbRUU= MIME-Version: 1.0 Sender: johncogg@gmail.com Received: by 10.151.15.13 with SMTP id s13mr2262557ybi.279.1247194947013; Thu, 09 Jul 2009 20:02:27 -0700 (PDT) In-Reply-To: <2B.30.23850.963965A4@pb1.pair.com> References: <7.0.1.0.2.20090708224156.0ac5a438@zend.com> <312025EF-84D0-4411-A0A7-4F0379C3105F@pooteeweet.org> <22CAD497EA2F476DAECEF9302D0B087A@pc> <98b8086f0907091150r47e7a103jaa50fcf7d5b32186@mail.gmail.com> <4A568B33.9000501@gmail.com> <98b8086f0907091744w7ab598dckc427d0a9484664b2@mail.gmail.com> <2B.30.23850.963965A4@pb1.pair.com> Date: Thu, 9 Jul 2009 20:02:26 -0700 X-Google-Sender-Auth: d292bddba75153e0 Message-ID: <1ae19b080907092002s7219220dg99b6d69d3b06f5ef@mail.gmail.com> To: PHP internals Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Type hinting - Request for Discussion From: john@coggeshall.org (John Coggeshall) All: I'm in favor of this so-called "Weak" typing Zeev has proposed as well, but I would like to see it become available in PHP before PHP 6. That doesn't mean it has to go into 5.3.x, but I don't see why there can't be a 5.4 that includes it. Personally, I think primitive typing has a much more immediate need than many of the features proposed for 6 and, considering there is already been numerous working patches that implement this feature in principal, I don't see why we can't have a 5.4 release including it. Waiting for PHP 6 is too long and the many serious time-consuming tasks that are required to achieve the goals of PHP 6 shouldn't stop a very useful feature like this from getting into the wild promptly. Secondly, I'd like to discuss a little something I thought about regarding when PHP will/will not throw an error dealing with primitive types. Specifically when dealing with user input (which always comes across as a string to start), if you had something like... function foo(int $a, int $b) { return $a + $b; } and called: foo($_GET['a'], $_GET['b']); // $_GET['a'] === "foo", $_GET['b'] === 5 According to Zeev's description of the behavior this would cause a fatal error, as $_GET['a'] cannot be converted to an integer value.. I like that, but I think we need to devise a mechanism that allows you to catch this error at runtime and write application logic around it... In the simple case above the point would be to be able to catch the error so that the requesting user could be informed he must enter two integer values. Off the top of my head the only mechanism that I can think of would be to throw an exception, which I'm not crazy about either: try { print foo($_GET['a'], $_GET['b']); } catch(TypeCheckException $e) { print "Sorry, you need to provide two integer values!"; } Personally I really like the practical feel and ease of understanding of using an exception in this case, but the idea of an exception being thrown from potentially procedural code isn't the best thing to me.. John