Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:81956 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 50332 invoked from network); 5 Feb 2015 18:50:34 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 5 Feb 2015 18:50:34 -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:45868] helo=imap11-2.ox.privateemail.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 94/68-27691-87BB3D45 for ; Thu, 05 Feb 2015 13:50:34 -0500 Received: from localhost (localhost [127.0.0.1]) by mail.privateemail.com (Postfix) with ESMTP id AE6AE880D59; Thu, 5 Feb 2015 13:50:29 -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 6gdnIl4cRqa3; Thu, 5 Feb 2015 13:50:29 -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 91B6A880941; Thu, 5 Feb 2015 13:50:27 -0500 (EST) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 8.2 \(2070.6\)) In-Reply-To: Date: Thu, 5 Feb 2015 18:50:25 +0000 Cc: Stanislav Malyshev , Sebastian Bergmann , PHP Internals Content-Transfer-Encoding: quoted-printable Message-ID: <5EFCBA22-D032-4444-8E11-F44FA07A722A@ajf.me> References: <00c101d04049$ca411ec0$5ec35c40$@tekwire.net> <54D1CA7C.8060204@php.net> <54D1E6EC.7060702@php.net> <54D2B3FA.6020900@gmail.com> To: Dmitry Stogov X-Mailer: Apple Mail (2.2070.6) Subject: Re: [PHP-DEV] What do we need strict scalar type hints for? From: ajf@ajf.me (Andrea Faulds) Hi, > On 5 Feb 2015, at 06:52, Dmitry Stogov wrote: >=20 > I completely agree. > Strict typing doesn't fit into PHP. It was already told thousand = times. Seems to work rather well in practice, so long as it=E2=80=99s optional. > Also, the only really useful case for "strict typing" is the ability = to catch mistakes in user apps. > However, this ability is really limited. Implementing "Design by = Contact" approach may be much smarter. It=E2=80=99s not that limited. I caught two different bugs in my app = simply by adding strict types. Strict typing, crucially, allows the catching of errors ahead of time, = too. You can=E2=80=99t do that with weak typing, because it depends on = the value, not the type. And you don=E2=80=99t know the value from = reading the source code. -- Andrea Faulds http://ajf.me/