Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:48394 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 29829 invoked from network); 22 May 2010 16:52:37 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 22 May 2010 16:52:37 -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:42236] helo=il-mr1.zend.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id E0/AB-46027-2DB08FB4 for ; Sat, 22 May 2010 12:52:36 -0400 Received: from il-gw1.zend.com (unknown [10.1.1.21]) by il-mr1.zend.com (Postfix) with ESMTP id 5D6BA504D3; Sat, 22 May 2010 19:29:38 +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:52:30 +0300 Message-ID: <7.0.1.0.2.20100522194236.0a5ff910@zend.com> X-Mailer: QUALCOMM Windows Eudora Version 7.0.1.0 Date: Sat, 22 May 2010 19:50:28 +0300 To: Josh Davis Cc: internals@lists.php.net In-Reply-To: References: <7.0.1.0.2.20100522175819.0a601c68@zend.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; format=flowed X-OriginalArrivalTime: 22 May 2010 16:52:30.0643 (UTC) FILETIME=[2AE13830:01CAF9CF] Subject: Re: [PHP-DEV] Type hinting From: zeev@zend.com (Zeev Suraski) At 19:30 22/05/2010, Josh Davis wrote: >On 22 May 2010 17:04, Zeev Suraski wrote: > > As one of the key people who designed PHP's type system I consider strict > > type checks completely alien to and counterintuitive in PHP and > am therefore > > pushing to implement 'weak' typing instead, in a way that's consistent and > > familiar to users. > >I would normally refrain from posting on the dev list but as a "user" >I feel the need to make sure that my position isn't misrepresented, so >here it is. I think that users' opinion about language direction is very important, so thanks for writing. >As you wrote, you worked on PHP's _type system_ which is dynamic, >really cool, juggles strings with ints and what not. However, the >topic here is the _type hinting system_. Well I actually wrote PHP's type hinting system too :) And it's no coincidence there are no type hints for scalars, and that stems directly from PHP's type system. As a part of introducing type hints to PHP back in 2003, there was a discussion about whether or not to add scalar type hints. Consensus was against it, and actually as a part of the agreement to add type hints to PHP - we agreed we'll 'never' introduce scalar type hints because of the baggage and inconsistency it comes with. Never is not a very long time when it comes to software though... >As far as I know, there's no >"weak" type hinting; if a method signature hints for an array and is >given an integer, it throws a catchable fatal error. Therefore, as a >user, what I am familiar to is a strict _type hinting system_. >Anything else would feel inconsistent to me. That's true, but then, there's also no way to auto-convert class Foo to class Bar - while there is a way to auto-convert between scalar types in many (if not most) cases. Consider a simple example - class Child extends Parent {} strict type hinting is the equivalent of not allowing an object of class Child when a function expects an object of class Parent. Much like Child is_a Parent, "123" is_a int. Zeev