Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:80457 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 77791 invoked from network); 14 Jan 2015 11:21:53 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 14 Jan 2015 11:21:53 -0000 Authentication-Results: pb1.pair.com header.from=ajf@ajf.me; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=ajf@ajf.me; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain ajf.me designates 192.64.116.200 as permitted sender) X-PHP-List-Original-Sender: ajf@ajf.me X-Host-Fingerprint: 192.64.116.200 imap1-2.ox.privateemail.com Received: from [192.64.116.200] ([192.64.116.200:42802] helo=imap1-2.ox.privateemail.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 43/23-61073-05156B45 for ; Wed, 14 Jan 2015 06:21:53 -0500 Received: from localhost (localhost [127.0.0.1]) by mail.privateemail.com (Postfix) with ESMTP id DB26CB0007B; Wed, 14 Jan 2015 06:21:49 -0500 (EST) X-Virus-Scanned: Debian amavisd-new at imap1.ox.privateemail.com Received: from mail.privateemail.com ([127.0.0.1]) by localhost (imap1.ox.privateemail.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id Ml_9n-M013W4; Wed, 14 Jan 2015 06:21:49 -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 95793B0008F; Wed, 14 Jan 2015 06:21:48 -0500 (EST) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 8.1 \(1993\)) In-Reply-To: Date: Wed, 14 Jan 2015 11:21:45 +0000 Cc: Julien Pauli , PHP Internals List Content-Transfer-Encoding: quoted-printable Message-ID: <1337AC4E-7705-4A5E-8CBB-8BBB0A18BB9D@ajf.me> References: <8DCD1B72-C81D-499E-B455-E4A042CD76E6@ajf.me> <76F9DAD3-5A22-4A53-8262-CF6B33D80FC3@ajf.me> To: Andrey Andreev X-Mailer: Apple Mail (2.1993) Subject: Re: [PHP-DEV] [RFC] Scalar Type Hints v0.2 From: ajf@ajf.me (Andrea Faulds) Hi Andrey, > On 14 Jan 2015, at 11:10, Andrey Andreev wrote: >=20 > I don't understand why it should be a bad thing that the API author > forces rules on the consumer. The opposite is IMO fundamental to the > concept of an API - the rules specified by the author are a contract > that the consumer agrees to, and which allows for the whole thing to > work properly. >=20 > In this form, I don't get any benefit from strict type checks, because > I only want them so that writing foo(int $bar) guarantees me that the > caller *passed* an integer. Instead, I'd have to NOT use a type hint, > and instead do an is_int($bar) check inside ... this beats the whole > purpose. Why? What is wrong with a caller choosing to use weak type hints? Either = way you receive an integer. > This caller-controlled switch very much reminds me of > mbstring.func_overload, which I didn't care much for, until one day I > saw how it breaks all crypto code that authors had otherwise written > very carefully. >=20 > I prefer Julien's (int) $weak vs. int $strong syntax better (which is > what I've always wanted), but I don't care much if it's a declare() > statement, just as long as the author controls the behavior. > And while I'm on that - thank you for this proposal (specifically the > 0.2 version), Andrea. Finally an RFC that allows both weak and strict > scalar type checks instead of the "can't go in both directions" > nonsense that has blocked this feature for years. I don=E2=80=99t like going in both directions if I=E2=80=99ll have to = deal with both at the same time. I want consistency. Either everything = weak or everything strict. That=E2=80=99s why I like this approach. At = least within a single file, everything will follow the same approach, = rather than it being mix-and-match. -- Andrea Faulds http://ajf.me/