Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:83345 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 99183 invoked from network); 20 Feb 2015 19:06:20 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 20 Feb 2015 19:06:20 -0000 Authentication-Results: pb1.pair.com header.from=ircmaxell@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=ircmaxell@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.215.48 as permitted sender) X-PHP-List-Original-Sender: ircmaxell@gmail.com X-Host-Fingerprint: 209.85.215.48 mail-la0-f48.google.com Received: from [209.85.215.48] ([209.85.215.48:36836] helo=mail-la0-f48.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id C4/2E-14173-AA587E45 for ; Fri, 20 Feb 2015 14:06:19 -0500 Received: by labgq15 with SMTP id gq15so8137669lab.3 for ; Fri, 20 Feb 2015 11:06:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=an+12846Byzy1tF9d9qpseoBJemMbF588r8avNKKFlE=; b=pENdtQ71zyEsv0ga7oJU47AcT0k1V1lKjUyBIvQdwm/ydvbrHr/Sp2HqMnNQEVZ/G7 nku94bjCvrpFXfWAKiSULaxLQhsEph/St2HDsdB3gTFyEbTU/RVLNDtpzGPbz10FaqkC Sizxa2SrWqCiq1NbieC+lsVNKhInB9WNWM1tm4fRSBwxKI/eSEd4SjDmTObI0Myrtq1Y yP90oFCpwalJDmM8VC/xTbsKp/XHQPYu96U++EDaiLQCxnfDsYujG9V2986xf5fIbjQB 10R067C+zm4aEcCgFEj4n4d4XujLXaAziKnE9BiZQwQ/HpR2es6H/6OkFmAEd43+QHgm S02w== MIME-Version: 1.0 X-Received: by 10.112.171.65 with SMTP id as1mr9821061lbc.45.1424459175749; Fri, 20 Feb 2015 11:06:15 -0800 (PST) Received: by 10.25.43.9 with HTTP; Fri, 20 Feb 2015 11:06:15 -0800 (PST) In-Reply-To: <54E77D2E.60407@lerdorf.com> References: <20150220170854.308596800F2@frontend2.nyi.internal> <54E77D2E.60407@lerdorf.com> Date: Fri, 20 Feb 2015 14:06:15 -0500 Message-ID: To: Rasmus Lerdorf Cc: Larry Garfield , "internals@lists.php.net" Content-Type: text/plain; charset=UTF-8 Subject: Re: [PHP-DEV] Reviving scalar type hints From: ircmaxell@gmail.com (Anthony Ferrara) Rasmus, > To be perfectly transparent here though, you should mention that your > proposed RFC goes well beyond the strict typing that is in Hack because > in Hack the internal API is largely untyped while your proposal is to > default the entire internal API to strict types in strict mode. Also, in > Hack there is a distinction between the off-line hh_client type-checker > and the runtime. In addition to what Josh said, I want to make one point here. This distinction is what lead me to push out 0.5 instead of where 0.4 was going. Let me explain: Let's say we don't type internal functions and release 7.1 with the rest of the dual mode type system. Then we're bound to never strictly type internal functions *unless* we introduce a NEW declare setting (declare(strict_types=2) or declare(internal_strict_types=1) or whatever). Which is a bit out there considering people already are testy about this one. So that practically means if we don't allow strict now, we can never tighten it again. However, if we do allow typed now, then we can expand and loosen in the future. If an API is found to be overly strict, it can be loosened (using a union type for example). We have the ability to loosen over time, but not strengthen. That's why I chose to apply the same typing to internal functions as user-land. To not to would be a major mistake IMHO. So that's why I'm moving forward with it. I will add this to discussion points in the RFC. > So when you say, and as I have heard other people say, that people want > Hack-like strict typing, you have to be a bit careful about what is > meant by that. Even in the cases where the internal API is typed in > Hack, it is still not a runtime fatal if they are called with the wrong > types. Now whether that is a good thing or not is debatable, of course, > my point is simply that if you are going to use Hack adoption as a sign > "that people want static typing" you should clearly explain that your > approach is quite different from what Hack is doing. It's not "quite different". It's subtly different in a few details. But conceptually it's the same. > Right, you are doing a gradual transition of an API that wasn't written > to be strict. It was written with the assumption that type coercion > would take place. If there is a good reason to ease the transition from > PHP to Hack there is an even stronger reason to ease the transition from > PHP to PHP. And that's why the current proposal has two modes: weak (coercive) and strict (error inducing). The default mode will not change things for anyone. Then they can start adding types, and things will just work. When they are ready, then they can turn on strict mode, one file at a time. Heck, they can run a strict-mode static analyzer on non-strict code to see where potential problems will be (assuming the analyzer has that mode) so they can fix it before committing to strict types in their production app. If that's not the definition of a "gradual transition", I'm not sure what else can be done without fundamentally disallowing the ability to strictly type. Anthony