Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:80576 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 44088 invoked from network); 15 Jan 2015 17:13:30 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 15 Jan 2015 17:13:30 -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.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:35036] helo=imap11-2.ox.privateemail.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id E7/12-34371-935F7B45 for ; Thu, 15 Jan 2015 12:13:29 -0500 Received: from localhost (localhost [127.0.0.1]) by mail.privateemail.com (Postfix) with ESMTP id C5EF88800EB; Thu, 15 Jan 2015 12:13:26 -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 Fi2zjzEguXME; Thu, 15 Jan 2015 12:13:26 -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 C38078800E7; Thu, 15 Jan 2015 12:13:24 -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 17:13:22 +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) Hi Mike, > On 15 Jan 2015, at 17:07, Mike Willbanks wrote: >=20 > I may not have described this clearly. If I make a library with a = method that states an int, the declarative syntax now makes me have to = take both due to your earlier comment on that userland would define the = condition. This means that if I declared handling inside my library to = be strict but the caller was in weak, I would need to handle that = condition. How, exactly, would you need to handle that condition? You don=E2=80=99t = need to do anything yourself. As the RFC itself says: > In both approaches, the function will always get exactly the argument = type it asks for. In the case of strict type-checking, this is done by = rejecting incorrectly-typed values. In the case of weak type-checking, = this is done by rejecting some values, and converting others. Therefore, = the following code will always work, regardless of mode: > function foobar(int $i) { > if (!is_int($i)) { > throw new Exception("Not an integer."); // this will never = happen > } > } No matter whether foobar() is called from strictly type-checked or = weakly type-checked code, the $i argument you get will always, without = fail, be an integer. Thus, I do not see how you "would need to handle = that condition=E2=80=9D. > Now from that perspective I cannot rely that I am in strict and would = have to handle the default weak even although I declared in my class = that i wanted strict mode which only affected the code inside of that = file. That's ultimately what I am saying and why I am stating it would = have to handle both conditions. In reality, you'd always act as if you = were in a weak mode supporting that case. I=E2=80=A6 really don=E2=80=99t understand, I=E2=80=99m sorry. Are you = complaining that if a caller uses the weak mode, they are not bound by = strict types? Why do you want to affect the code of the caller? -- Andrea Faulds http://ajf.me/