Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:34377 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 96847 invoked by uid 1010); 4 Jan 2008 00:25:44 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 96832 invoked from network); 4 Jan 2008 00:25:44 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 4 Jan 2008 00:25:44 -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:48908] helo=scottsdale.servershost.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id F0/67-20810-70D7D774 for ; Thu, 03 Jan 2008 19:25:44 -0500 Received: from [208.58.196.175] (port=50888 helo=[192.168.1.92]) by scottsdale.servershost.net with esmtpsa (SSLv3:RC4-MD5:128) (Exim 4.68) (envelope-from ) id 1JAaNb-0004wa-K9; Thu, 03 Jan 2008 18:25:43 -0600 To: Stanislav Malyshev Cc: internals@lists.php.net In-Reply-To: <477D58ED.6030101@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> <1199395138.15292.72.camel@sbarrow-desktop> <477D58ED.6030101@zend.com> Content-Type: text/plain Date: Thu, 03 Jan 2008 19:25:33 -0500 Message-ID: <1199406333.5889.2.camel@e-vectra> 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) The value is this: With type hinting: function a(string $mystring, num $mynum, object $myobject) { } Without type hinting: function a($mystring, $mynum, $myobject) { if (!is_string($mystring)) { trigger_error('Parameter 1 of function a() must be a string.', E_USER_WARNING) ; } if (!is_int($mynum) and !is_float($mynum)) { trigger_error('Parameter 2 of function a() must be a number.', E_USER_WARNING) ; } if (!is_object($myobject) { trigger_error('Parameter 3 of function a() must be an object.', E_USER_WARNING) ; } } On Thu, 2008-01-03 at 13:51 -0800, Stanislav Malyshev wrote: > > 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 > > So now to use such function you'd have to check your variables for > typing - otherwise your application blows up. And the type-checking > should be total - otherwise you miss some call to some function or some > code path bringing wrong value and your application blows up at runtime > - since static type checking is not available. Meaning, unless all of > your code is type-enforced, you'd have to write a wrapper around each > type-enforced function manually checking that wrong value didn't get in. > But you can do the same checks now, so what is the added value?