Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:34402 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 34423 invoked by uid 1010); 4 Jan 2008 13:29:14 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 34408 invoked from network); 4 Jan 2008 13:29:14 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 4 Jan 2008 13:29:14 -0000 Authentication-Results: pb1.pair.com header.from=sam@sambarrow.com; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=sam@sambarrow.com; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain sambarrow.com from 205.234.132.11 cause and error) X-PHP-List-Original-Sender: sam@sambarrow.com X-Host-Fingerprint: 205.234.132.11 scottsdale.servershost.net Received: from [205.234.132.11] ([205.234.132.11:59822] helo=scottsdale.servershost.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id F3/90-29353-AA43E774 for ; Fri, 04 Jan 2008 08:29:14 -0500 Received: from [98.172.154.66] (port=52437 helo=[10.200.100.14]) by scottsdale.servershost.net with esmtpsa (SSLv3:RC4-MD5:128) (Exim 4.68) (envelope-from ) id 1JAmbl-0001Us-9P; Fri, 04 Jan 2008 07:29:09 -0600 To: Tomi Kaistila Cc: internals@lists.php.net In-Reply-To: <200801041006.53836.tomi@cumulo.fi> References: <200801031903.01980.tomi@cumulo.fi> <698DE66518E7CA45812BD18E807866CE01103E21@us-ex1.zend.net> <200801041006.53836.tomi@cumulo.fi> Content-Type: text/plain Date: Fri, 04 Jan 2008 08:27:38 -0500 Message-ID: <1199453258.15292.101.camel@sbarrow-desktop> Mime-Version: 1.0 X-Mailer: Evolution 2.10.1 Content-Transfer-Encoding: 7bit X-Antivirus-Scanner: Clean mail though you should still use an Antivirus X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - scottsdale.servershost.net X-AntiAbuse: Original Domain - lists.php.net X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - sambarrow.com X-Source: X-Source-Args: X-Source-Dir: Subject: Re: [PHP-DEV] RE: Optional scalar type hinting From: sam@sambarrow.com (Sam Barrow) On Fri, 2008-01-04 at 10:06 +0200, Tomi Kaistila wrote: > > It really doesn't fit in very well with PHP's loosely typed nature which > > is one of the main reasons it has been so easy to use. > I think this is one of the cornerstones that two sides disagree the most on. > People are afraid that PHP would turn into a strong-typed language by > allowing type hinting for scalar values. I do not think this would be the > case. You would still have all the freedom that you have no with PHP, since > PHP's type juggling is still in effect. > > The only thing that would change is that the validation of the data that is > passed into functions would be somewhat automated, but since the validation > occurs with or without type hinting the result is still the same. If data is > incorrent, an error occurs whether it is an exception, a false return type, > or a triggered error. The behaviour of the program does not change with type > hinting. Exactly. This is not strict typing. It's type hinting (key word, hinting). > > Even this thread shows that there's no alignment between people on what > > it should actually do. > This is true, but contributed to it is that so far we have spent more time and > energy on the silly debate whether or not type hinting is a useful feature. > There is enough technical proof to suggest that it is in fact a useful > feature. > > What I would like to see is actual discussion on how it should behave and see > if a concensus can be derived. > > > Saying that it won't confuse newbies is also wrong. PHP is so popular > > because it's so easy for people to pick up. Part of this also includes > > ability to look at other people's code, understand it, copy-on-write > > (e.g. a Wordpress plug-in). > This is an argument that I honestly do not understand. Type hinting is already > here. It exists in PHP. How can the concept be abandoned on the bases that it > would confuse new users, if the concept has already been approved and > implemented? > Exactly, array and class type hints are actually more confusing than scalar type hints. What's more confusing to a beginner, having to pass an instance of a certain object to a function, or having to pass a number or string? > > Tomi Kaistila > PHP Developer >