Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:34353 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 20854 invoked by uid 1010); 3 Jan 2008 21:20:32 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 20839 invoked from network); 3 Jan 2008 21:20:32 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 3 Jan 2008 21:20:32 -0000 Authentication-Results: pb1.pair.com smtp.mail=sam@sambarrow.com; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=sam@sambarrow.com; 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:47742] helo=scottsdale.servershost.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 8B/89-20810-E915D774 for ; Thu, 03 Jan 2008 16:20:32 -0500 Received: from [98.172.154.66] (port=24829 helo=[10.200.100.14]) by scottsdale.servershost.net with esmtpsa (SSLv3:RC4-MD5:128) (Exim 4.68) (envelope-from ) id 1JAXUJ-0005oq-EJ; Thu, 03 Jan 2008 15:20:27 -0600 To: Stanislav Malyshev Cc: internals@lists.php.net In-Reply-To: <477D4ACF.3030006@zend.com> References: <200801031903.01980.tomi@cumulo.fi> <1199380881.15292.11.camel@sbarrow-desktop> <20080103172813.GQ7861@mint.phcomp.co.uk> <477D2B40.9010302@fischer.name> <477D2CDB.3000005@zend.com> <477D452A.9090906@zend.com> <1199392531.15292.64.camel@sbarrow-desktop> <477D4ACF.3030006@zend.com> Content-Type: text/plain Date: Thu, 03 Jan 2008 16:18:58 -0500 Message-ID: <1199395138.15292.72.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 Thu, 2008-01-03 at 12:51 -0800, Stanislav Malyshev wrote: > > In a way this is true, but I look at it this way. Some languages are > > strictly typed, some are dynamically typed. PHP can have the best of > > both worlds by having optional strict typing where desired, as well as > > I do not believe trying to both eat cake and leave it intact would do us > well. Mixing strict and non-strict code would be a nightmare. Absence of > static type control (necessary for interpreted language) would make > strictly typed code less, and not more stable. Add performance penalty > from type checking and effort would be required from PHP newcomers to > understand two code models instead of one - and you get the worst of > both worlds, not the best. But this is not all-out strict typing. This is simply checking types on execution of a function. I wrote the patch to follow the exact same model as array type hinting. The only difference is that instead of checking if the value is an array, it checks if it is an integer, string, bool, etc. There aren't two code models here at all. You can have a function parameter, or you can have a type-enforced function parameter. PHP newcomers can just not use type hinting if they want but I don't think this is a valid argument. As for performance, you may have a point. However it is probably no worse than array type hinting, and it's definitely faster than class type hinting, which were both deemed useful for PHP 5.1. > > Strict typing allows very little room for type conversion. This is > > optionally hinting the desired type of a function parameter. > > That's not what I am hearing here on the list. Sorry I don't understand, what is it you are not hearing on the list?