Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:34447 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 20748 invoked by uid 1010); 4 Jan 2008 18:58:41 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 20733 invoked from network); 4 Jan 2008 18:58:41 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 4 Jan 2008 18:58:41 -0000 Authentication-Results: pb1.pair.com smtp.mail=andi@zend.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=andi@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: andi@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:34295] helo=mx1.zend.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 80/DD-63281-0E18E774 for ; Fri, 04 Jan 2008 13:58:41 -0500 Received: from us-ex1.zend.com ([192.168.16.5]) by mx1.zend.com with Microsoft SMTPSVC(6.0.3790.3959); Fri, 4 Jan 2008 20:58:37 +0200 X-MimeOLE: Produced By Microsoft Exchange V6.5 Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: quoted-printable Date: Fri, 4 Jan 2008 10:58:34 -0800 Message-ID: <698DE66518E7CA45812BD18E807866CE01103EE2@us-ex1.zend.net> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: [PHP-DEV] type hinting Thread-Index: AchPArFZAR5pKE7gSUKGG3AW4RV6WAAABuuQ References: <477DB7BF.10201@chiaraquartet.net> <20080104105558.GC7861@mint.phcomp.co.uk> <477E5649.2080104@chiaraquartet.net> <477E619C.2050107@sektioneins.de> <477E78D0.3050501@zend.com> <698DE66518E7CA45812BD18E807866CE01103ED3@us-ex1.zend.net> <1199472536.15292.185.camel@sbarrow-desktop> To: "Sam Barrow" Cc: "Ilia Alshanetsky" , "Stas Malyshev" , "internals Mailing List" X-OriginalArrivalTime: 04 Jan 2008 18:58:37.0955 (UTC) FILETIME=[D060A530:01C84F03] Subject: RE: [PHP-DEV] type hinting From: andi@zend.com ("Andi Gutmans") Look it boils down to the following: True type enforcement ala =3D=3D=3D (i.e. you pass "1" to an int and it = errors out) does not make sense for PHP (and yes, philosophy and design goals of the language are important). Forget even the argument that this is not how PHP works all around and is inconsistent with what we've done from day 1 but more importantly if you are going towards strict typing then you need a type system to implement that during "compile-time" (i.e. like C or Java). You otherwise loose out because you are pushing out all these type problems into production and it'll lead to too many production errors, often when it may not have to be an error. What I suggested in my previous email is type hinting which also does the conversion to the request type. This is very much in the PHP spirit and also how PHP's internal functions work today. It is "consistent". Copy&pasting from my previous email the following would work: function iwantint(int $n) { iwantint("1"); // "1" + 1 works great. function iwantstring(string $str) {} iwantstring($toStringObject); // Works in strcmp() function iwantfloat(float $f) {} iwantfloat(2); function iwantbool(bool $b) {} iwantbool(1); But honestly adding strict type hinting ala (int =3D=3D=3D int) just = does not make sense in this language. There's a reason why C/Java are able to enforce this at compile-time and don't push this equality into runtime. It's not we are right or wrong vs. those languages it's that those languages take it all the way and when requiring true strict typing they do it right. In PHP this equates to extending PHP with C. Andi > -----Original Message----- > From: Sam Barrow [mailto:sam@sambarrow.com] > Sent: Friday, January 04, 2008 10:49 AM > To: Andi Gutmans > Cc: Ilia Alshanetsky; Stas Malyshev; internals Mailing List > Subject: RE: [PHP-DEV] type hinting >=20 > On Fri, 2008-01-04 at 10:37 -0800, Andi Gutmans wrote: > > I think the "mixed" identifier is a minor issue but I also don't see > > it's purpose. If you don't want type hinting then don't write a type > > hint. It's also tool friendly... > > Andi >=20 > It is kind of pointless, just syntactic sugar to be honest. Not a big > deal at all though. I'd like it as I said for the syntactic sugar but > personally I don't care too much.