Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:80572 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 35509 invoked from network); 15 Jan 2015 16:59:38 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 15 Jan 2015 16:59:38 -0000 Authentication-Results: pb1.pair.com smtp.mail=ajf@ajf.me; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=ajf@ajf.me; sender-id=pass Received-SPF: pass (pb1.pair.com: domain ajf.me designates 192.64.116.199 as permitted sender) X-PHP-List-Original-Sender: ajf@ajf.me X-Host-Fingerprint: 192.64.116.199 imap11-2.ox.privateemail.com Received: from [192.64.116.199] ([192.64.116.199:51085] helo=imap11-2.ox.privateemail.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 84/20-34371-9F1F7B45 for ; Thu, 15 Jan 2015 11:59:37 -0500 Received: from localhost (localhost [127.0.0.1]) by mail.privateemail.com (Postfix) with ESMTP id A13B18800EC; Thu, 15 Jan 2015 11:59:34 -0500 (EST) X-Virus-Scanned: Debian amavisd-new at imap11.ox.privateemail.com Received: from mail.privateemail.com ([127.0.0.1]) by localhost (imap11.ox.privateemail.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id Qt1MgQlDdPL2; Thu, 15 Jan 2015 11:59:34 -0500 (EST) Received: from oa-res-26-240.wireless.abdn.ac.uk (oa-res-26-240.wireless.abdn.ac.uk [137.50.26.240]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.privateemail.com (Postfix) with ESMTPSA id 345EB8800F3; Thu, 15 Jan 2015 11:59:33 -0500 (EST) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 8.1 \(1993\)) In-Reply-To: Date: Thu, 15 Jan 2015 16:59:30 +0000 Cc: Zeev Suraski , Richard Quadling , Leigh , PHP Internals List Content-Transfer-Encoding: quoted-printable Message-ID: References: <8DCD1B72-C81D-499E-B455-E4A042CD76E6@ajf.me> <4E2073DE-0951-498C-97BB-DDAC094F11FA@ajf.me> <9a033dd1f223f854e760924d118ab812@mail.gmail.com> <2ae0164cb9b9bf1c974d7a3c60af0466@mail.gmail.com> <6105ea99002e634373c09685310e26a6@mail.gmail.com> To: Mike Willbanks X-Mailer: Apple Mail (2.1993) Subject: Re: [PHP-DEV] [RFC] Scalar Type Hints v0.2 From: ajf@ajf.me (Andrea Faulds) Hello Mike, > On 15 Jan 2015, at 16:55, Mike Willbanks wrote: >=20 > I actually quite disagree with that statement. I don=E2=80=99t understand. I said "either approach to scalar hints will = upset a large portion of the community=E2=80=9D. Are you not = demonstrating that point, in that you don=E2=80=99t like the strict = approach? > Both as a library/framework developer and a user land developer I = find strict typing to be more of an issue. For instance: >=20 > function foo(int $foo) > foo('23'); >=20 > This would be a pain and cause constant glue from userland: > Option A: Force Cast aka (int) '23' > Option B: Check for digits via ctype_digits then force cast > etc. >=20 > To provide more of a point here, variables coming from HTTP are always = a string, this makes strict casting a troubling item, considering that = the main way of fetching input is coming from the web specifically. I'm = certain this would also affect other areas as well such as reading csv = files and more. To me this point alone makes a vastly strong statement = against strict typing and as such, it would make life far more difficult = for library developers and user land developers alike. Well, this RFC doesn=E2=80=99t force you to use strict type checking. = Quite the opposite. > I agree with the others in that declarative syntax to change it is a = bad idea. It actually reminds me of ECMAScript 5's "use strict" = (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_= mode) condition. Changing the definition based on user land scripts = can lead to bugs and inconsistencies in a library developers purpose of = a package and cause bad conditions. It also means that then a library = developer would need to handle conditions on both sides (when in weak = vs. strict). No, the library developer would never need to =E2=80=9Chandle both = cases=E2=80=9D. Your library always gets the type it asks for. The RFC = is quite clear on this. Your code will always behave exactly the same. Thanks. -- Andrea Faulds http://ajf.me/