Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:37076 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 71601 invoked from network); 17 Apr 2008 16:00:10 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 17 Apr 2008 16:00:10 -0000 Authentication-Results: pb1.pair.com header.from=pierre.php@gmail.com; sender-id=pass; domainkeys=bad Authentication-Results: pb1.pair.com smtp.mail=pierre.php@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 66.249.92.174 as permitted sender) DomainKey-Status: bad X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: pierre.php@gmail.com X-Host-Fingerprint: 66.249.92.174 ug-out-1314.google.com Received: from [66.249.92.174] ([66.249.92.174:7052] helo=ug-out-1314.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 7E/1E-05127-FF377084 for ; Thu, 17 Apr 2008 12:00:00 -0400 Received: by ug-out-1314.google.com with SMTP id u40so1179658ugc.29 for ; Thu, 17 Apr 2008 08:59:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; bh=UHGrKCe/CAYF/+Mb0jLqc+ANquWYb9zWY9yyow7NJoI=; b=ktc08J8xOEMLO19nPR5AqnIEbtfzf5GtLQAlIE1YVwWTPs2NfOhDgoGvlzS7YKSei5yyvGZRasNRAGGgYP7S/feoSvTKHUi7zTzq3wqRTVX85ISXb5kAOshV7NL/J4rdD6N3D1Dbv2eTKGWTkpcIQR1Q6Rd//PUlu5PkyVzqZME= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=E4o7yRuA6s5r4qr5WdmXb/36HZMOt1EzB5l+Cwfe4sOFZOQinb3LBxSrTA5lXTrOqcGdDE+7ZT6/X4quO7e41hixVn9DLcLE3vFUykcyS3ytbVy1kYXSNrOWTyH55jAMBzJmGJaEm4tIEI25RUVZXePic/lHBwQ7leliW9hwTPc= Received: by 10.67.116.6 with SMTP id t6mr8607961ugm.76.1208447995261; Thu, 17 Apr 2008 08:59:55 -0700 (PDT) Received: by 10.66.245.14 with HTTP; Thu, 17 Apr 2008 08:59:55 -0700 (PDT) Message-ID: Date: Thu, 17 Apr 2008 17:59:55 +0200 To: "Christian Schneider" Cc: "Felipe Pena" , internals@lists.php.net In-Reply-To: <48076FB3.1040303@cschneid.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <46ccd1ab0804170742g142ed562t4f03339da549a820@mail.gmail.com> <48076FB3.1040303@cschneid.com> Subject: Re: [PHP-DEV] Re: [RFC] Strict type hints (parameter and return value) From: pierre.php@gmail.com ("Pierre Joye") Hi Christian, On Thu, Apr 17, 2008 at 5:41 PM, Christian Schneider wrote: > Felipe Pena wrote: > > Well, thinking better about the behavior of type hinting, i decided to > > change the proposal for strict type. I.e. don't accept numeric string > > as an intenger, etc. > > While it is now consistent with is_int() it means we end up with strict > but also stupid interfaces and hence lots of silly type conversions in > application code using such a function. > This is especially annoying as you normally have very few > implementations of a function but lots of code calling it. > > You basically 'progressed' from > function foo($x) { $x = (int)$x; ... } # One place where type is > ensured or converted > foo(42); > foo(CONSTANT_42); > foo($x); > foo($db->x); > to > function foo(int $x) { ... } > foo(42); > foo((int)CONSTANT_42); # If you are not 100% about type > foo((int)$x); # If you are not 100% about type > foo((int)$db->x); # DBs normally return strings You slowly understand the idea behind strict type hinting, you should add these examples to the wiki ;-) More seriously, it should be about time to stop to argue about why you consider it useless, not the PHP way, too many to write, usw... But to consider the proposal and the patch on their own and if the feature will be added, is it the way we like to have it or how can it be improved (keeping the goal in mind). Whether PHP will have it or not is not yet decided, as far as I can say. But I really like to have it (I don't feel like explaining again why I like it is worth the bandwidth :) Cheers, -- Pierre http://blog.thepimp.net | http://www.libgd.org