Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:48395 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 31236 invoked from network); 22 May 2010 16:58:33 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 22 May 2010 16:58:33 -0000 Authentication-Results: pb1.pair.com smtp.mail=zeev@zend.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=zeev@zend.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain zend.com designates 212.25.124.185 as permitted sender) X-PHP-List-Original-Sender: zeev@zend.com X-Host-Fingerprint: 212.25.124.185 il-mr1.zend.com Received: from [212.25.124.185] ([212.25.124.185:38460] helo=il-mr1.zend.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id FA/EB-46027-73D08FB4 for ; Sat, 22 May 2010 12:58:33 -0400 Received: from il-gw1.zend.com (unknown [10.1.1.21]) by il-mr1.zend.com (Postfix) with ESMTP id D6AB2504D3; Sat, 22 May 2010 19:35:35 +0300 (IDT) Received: from LAP-ZEEV.zend.com ([10.1.20.36]) by il-gw1.zend.com with Microsoft SMTPSVC(6.0.3790.3959); Sat, 22 May 2010 19:58:28 +0300 Message-ID: <7.0.1.0.2.20100522195032.0a6010e0@zend.com> X-Mailer: QUALCOMM Windows Eudora Version 7.0.1.0 Date: Sat, 22 May 2010 19:58:27 +0300 To: Ilia Alshanetsky Cc: internals@lists.php.net In-Reply-To: References: <7.0.1.0.2.20100522175819.0a601c68@zend.com> <7.0.1.0.2.20100522190821.19934438@zend.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; format=flowed X-OriginalArrivalTime: 22 May 2010 16:58:28.0125 (UTC) FILETIME=[FFF4A4D0:01CAF9CF] Subject: Re: [PHP-DEV] Type hinting From: zeev@zend.com (Zeev Suraski) At 19:25 22/05/2010, Ilia Alshanetsky wrote: >Zeev, > >First of all as far as I can tell majority of the changes relate to >2 new type hints you are suggesting to introduce which are numeric >and scalar. I don't see any issue with adding those two hints, >predominantly for people who don't want to be specific with their >type requirements. So, +1 on that portion of the RFC. The majority of changes (make sure you look at the latest version as of about an half an hour ago) is not in terms of what's in there, but what isn't ('less is more'). The other major change is auto-conversion when possible, instead of failure. >However, after reviewing your suggested changes to some of the >type-specific hints, I think the changes you are suggesting would >only introduce confusion. There is a substantial WTF factor for >developers, whereby (int)1 === boolean, but (int)12 !== boolean. Or >that (int) 12 is either a valid int or a double, but (double)12 is >only a double. I think you make a good case, and it wasn't easy to decide how much (if at all) the auto-conversion rules should be stricter than PHP's default type conversion rules. I think we can tweak that table. The only ones I feel strongly about is that we shouldn't accept "abc" strings as numbers, or arrays/objects as any scalar type. Had we designed the language from scratch today, we would have probably not accepted those for auto-conversion either. >For one strict type hints are much clearer, if function/method >expects type X and anything but type X is provided an error is generated. They may be simpler for you and me to understand, but IMHO not for the general PHP userbase. Moreover - the fact they may be clearer to some doesn't necessarily make them more useful. I think auto-converting type hints are much more useful than strict ones (for reasons explained in the updated RFC). Zeev