Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:36859 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 77803 invoked from network); 7 Apr 2008 21:40:10 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 7 Apr 2008 21:40:10 -0000 Authentication-Results: pb1.pair.com smtp.mail=cschneid@cschneid.com; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=cschneid@cschneid.com; sender-id=unknown Received-SPF: error (pb1.pair.com: domain cschneid.com from 195.226.6.51 cause and error) X-PHP-List-Original-Sender: cschneid@cschneid.com X-Host-Fingerprint: 195.226.6.51 darkcity.gna.ch Linux 2.6 Received: from [195.226.6.51] ([195.226.6.51:35296] helo=mail.gna.ch) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 31/70-26449-8B49AF74 for ; Mon, 07 Apr 2008 17:40:09 -0400 Received: from localhost (localhost [127.0.0.1]) by darkcity.gna.ch (Postfix) with ESMTP id 24D8A16EC27; Mon, 7 Apr 2008 23:40:06 +0200 (CEST) Received: from unknown by localhost (amavisd-new, unix socket) id client-XXzWik6m; Mon, 7 Apr 2008 23:40:02 +0200 (CEST) Received: from box.local (84-72-92-81.dclient.hispeed.ch [84.72.92.81]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by darkcity.gna.ch (Postfix) with ESMTP id CEA8016EC0D; Mon, 7 Apr 2008 23:40:02 +0200 (CEST) Message-ID: <47FA94B2.6050704@cschneid.com> Date: Mon, 07 Apr 2008 23:40:02 +0200 User-Agent: Thunderbird 2.0.0.12 (Macintosh/20080213) MIME-Version: 1.0 To: RQuadling@GoogleMail.com CC: internals Mailing List References: <1207539695.5736.42.camel@pena> <8d7b8c130804062157j60871630r6c3b27c4d3245cb9@mail.gmail.com> <1207576676.5331.49.camel@felipe> <47FA507D.2070108@cschneid.com> <10845a340804071346m251eae49j907b4a6ca7c607be@mail.gmail.com> In-Reply-To: <10845a340804071346m251eae49j907b4a6ca7c607be@mail.gmail.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: amavisd-new at gna.ch Subject: Re: [PHP-DEV] Return type hints From: cschneid@cschneid.com (Christian Schneider) Richard Quadling schrieb: > Type juggling just doesn't seem to fit well with me. You seem to live in a completely different PHP world. Because in our case we use (yes, knowingly use) the PHP type juggling and it safes us lots of manual type conversions. We get input from all different sources as strings (_GET, MySQL, files) and in a lot of cases we just use it. We don't care if it's a string, a number or a float (or even null), if it yields the right result in our calculation it's fine. Now if a function only expects int (and truncates floats because of that) like array_reduce does with the $initial parameter then this function is crippled (for no good reason). Promoting type hints for PHP (and more so scalar type hints, especially specific scalar type hints like int) might give the impression to API developers that highly specified interfaces are better than more general ones. If we can learn something from the current hype around functional languages then it is the fact that generic, data type independant functions can be a very powerful tool. Something like array_* should be as generic as possible and API developers should also be aware of this topic and be given the right signals. Therefore my conclusion (abusing Einstein ;-)): Make interfaces as specific as *necessary* but *not more*. - Chris