Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:58421 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 88574 invoked from network); 1 Mar 2012 19:37:18 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 1 Mar 2012 19:37:18 -0000 Authentication-Results: pb1.pair.com header.from=johncrenshaw@priacta.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=johncrenshaw@priacta.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain priacta.com designates 64.95.72.244 as permitted sender) X-PHP-List-Original-Sender: johncrenshaw@priacta.com X-Host-Fingerprint: 64.95.72.244 mxout.myoutlookonline.com Received: from [64.95.72.244] ([64.95.72.244:19662] helo=mxout.myoutlookonline.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 38/50-19316-DEFCF4F4 for ; Thu, 01 Mar 2012 14:37:17 -0500 Received: from mxout.myoutlookonline.com (localhost [127.0.0.1]) by mxout.myoutlookonline.com (Postfix) with ESMTP id DF3F67E68F1; Thu, 1 Mar 2012 14:37:14 -0500 (EST) X-Virus-Scanned: by SpamTitan at mail.lan Received: from HUB013.mail.lan (unknown [10.110.2.1]) by mxout.myoutlookonline.com (Postfix) with ESMTP id 7700B7E68AF; Thu, 1 Mar 2012 14:37:14 -0500 (EST) Received: from MAILR001.mail.lan ([10.110.18.27]) by HUB013.mail.lan ([10.110.17.13]) with mapi; Thu, 1 Mar 2012 14:37:10 -0500 To: jpauli , Simon Schick CC: Richard Lynch , "internals@lists.php.net" Date: Thu, 1 Mar 2012 14:37:09 -0500 Thread-Topic: [PHP-DEV] PHP Philosophy (was RE: [PHP-DEV] Scalar type hinting) Thread-Index: Acz3mmo9defxVKIvRjy8ATt92epwbQARxCLw Message-ID: References: <693e15008681dfe7372eaea66214f8a8.squirrel@www.l-i-e.com> <4F4D5D44.5090307@developersdesk.com> In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: acceptlanguage: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: RE: [PHP-DEV] PHP Philosophy (was RE: [PHP-DEV] Scalar type hinting) From: johncrenshaw@priacta.com (John Crenshaw) > > > From: Richard Lynch [mailto:ceo@l-i-e.com] > > > On Wed, February 29, 2012 7:16 pm, John Crenshaw wrote: > > > > I'm beginning to think that the type hinting question is too closel= y > > > > related to the dirty secrets of type juggling to resolve them > > > > separately. You may have to either discard consistency, or else fix > > > > the problem of silent bizarre conversions at the same time ('foo'= =3D=3D0, > > > > '123abc'=3D123). Fixing the conversions is a BC break though. > > > > > > [short version] > > > One man's "fixing" is another man's "feature" :-) > > > > > > Old hands can now hit delete while I wax philosophical. > > > > The operative word was "silent". The actual behavior is fine, but the > > silence is unexpected. For example, PHP happily accepts substr('foo', > > 'bar') with no complaint at all. From a purely philosophical perspectiv= e I > > think almost everyone would expect *at least* a strict notice. > > > > On a practical level, we have a major barrier and we'll have to decide = how > > to handle it. As I see it we could do one of the following: > > 1. Discard consistency (!!) > > 2. Try to convince people to make these bizarre conversions not silent = (BC > > break) > > 3. Try to find a creative solution to be consistent without changing > > anything about the conversion behavior. (I'm not seeing a way to do thi= s > > one, unless we redefine "consistent".) > > > > John Crenshaw > > Priacta, Inc. > > > > -- > > PHP Internals - PHP Runtime Development Mailing List > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > > > On Thu, Mar 1, 2012 at 9:52 AM, Simon Schick wrote: > Hi, John > > Just to add an idea to yours .. > > Do you think it's a compatibility-break if we'd decide to send a E_NOTICE > or E_WARNING if we f.e. try to give a string to a method that just allows > integer for this argument? > No break at all, just a E_NOTICE or E_WARNING as the script can succeed > anyways. > Perhaps I missed something, but since 5.3, the new parameter parsing API > throws a Warning when types are not strictly honored. > This has been a major feature in favor of "cleaner" programming. > > Try substr('foo', 'bar'), in PHP >=3D 5.3 and you get a warning and the > function returns null. > > Julien.P > =20 > Bye > Simon > Ah, didn't notice the *new* behavior. That simplifies things substantially. I also had another realization today, which is that there's already strong = precedent for treating parameter hints more aggressively than a type cast. = For example, you can cast between arrays and objects, with no errors, but t= he type hints will still generate errors. I think this settles the consiste= ncy issue for me. John Crenshaw Priacta, Inc.