Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:82066 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 26862 invoked from network); 6 Feb 2015 20:22:49 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 6 Feb 2015 20:22:49 -0000 Authentication-Results: pb1.pair.com smtp.mail=nikita.ppv@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=nikita.ppv@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.212.174 as permitted sender) X-PHP-List-Original-Sender: nikita.ppv@gmail.com X-Host-Fingerprint: 209.85.212.174 mail-wi0-f174.google.com Received: from [209.85.212.174] ([209.85.212.174:53753] helo=mail-wi0-f174.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 27/71-19086-89225D45 for ; Fri, 06 Feb 2015 15:22:48 -0500 Received: by mail-wi0-f174.google.com with SMTP id n3so5210443wiv.1 for ; Fri, 06 Feb 2015 12:22:45 -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=qpXvObFFYFmMLkXagvbvQqEVF4PRCw5q9sy6v3WjOT0=; b=yJmu03ae5dNoP7li/Ai75teO40CwDzZQzdoy0/9D1mG9D5zaRfpLg9A/NGoXUC/ei6 0P9LdgAbA2TqyrPCSXSk0iGk6tdetu6bzQsGFuDYe4xnNFVNN4m1J4bz/RhPPMR8KfYV lyj6JLavm5/Dnov2eFvDI60Hy9OfYmBHwbqhQ0SVe3kGl9sVoYjll/KZMuQEz+AEeO6K hMPEITcBxfYhOck/orzGyk84XDjfZVFvX0dl+DOk1HHmOsF2KekAuI1tyy8uNW6ys8wM 5GuF3BIC5SNbBmQxg5c1Be1YffihWN8ahENm7BtPUPxMvGAHIrHCOuu4bIzxCzKzK7Sa x2lA== MIME-Version: 1.0 X-Received: by 10.180.75.80 with SMTP id a16mr6906135wiw.3.1423254165019; Fri, 06 Feb 2015 12:22:45 -0800 (PST) Received: by 10.27.10.138 with HTTP; Fri, 6 Feb 2015 12:22:44 -0800 (PST) In-Reply-To: <8703B53E-2C4A-4AC6-95C4-D4F19C6D5221@ajf.me> References: <8703B53E-2C4A-4AC6-95C4-D4F19C6D5221@ajf.me> Date: Fri, 6 Feb 2015 21:22:44 +0100 Message-ID: To: Andrea Faulds Cc: PHP Internals Content-Type: multipart/alternative; boundary=f46d043894f9ee61e2050e712e46 Subject: Re: [PHP-DEV] [VOTE] Scalar Type Hints From: nikita.ppv@gmail.com (Nikita Popov) --f46d043894f9ee61e2050e712e46 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On Thu, Feb 5, 2015 at 9:14 PM, Andrea Faulds wrote: > Good evening, > > At long last, I=E2=80=99m going to put the RFC to a vote. It=E2=80=99s be= en long enough - > I don=E2=80=99t think there needs to be, or will be, much further discuss= ion. > > I=E2=80=99d like to make sure that everyone voting understands the RFC fu= lly. > Please read the RFC in full: the details are important. And if anyone ha= s > any questions or uncertainties, please ask them before voting. I am very > happy to answer them. > > I would urge everyone who wants type hints to vote for this RFC. It is no= t > a perfect solution, but there can be no perfect solution to this issue. > However, I think it is better than most of the alternatives suggested thu= s > far - see the rationale section, and previous discussions. Crucially, thi= s > RFC would keep PHP a weakly-typed language, and not force either strict > typing, nor weak typing, on anyone who does not want it. It would allow t= he > addition of type hints to existing codebases. It would not create a > situation where userland functions are strict yet internal functions are > not, because the strict mode affects both. I=E2=80=99ve tested the implem= entation > myself on my own code, and it worked well, providing benefits other > proposals would not have given (see my previous post about my experiences= ). > > Voting starts today (2015-02-05) and ends in two weeks=E2=80=99 time (201= 5-02-19). > In addition to the vote on the main RFC, there is also a vote on the type > aliases issue, and a vote to reserve the type names for future RFCs=E2=80= =99 sake > if this RFC fails. > > The RFC can be found here, and it contains a voting widget: > https://wiki.php.net/rfc/scalar_type_hints > > Thank you for your time. > After much initial reluctance, I've voted in favor of this RFC. I'm a proponent of strict scalar typing. I will not explain the reasons behind this here, because they have been covered extensively in the previous threads and I no longer have the patience for such heavily prejudiced discussions. As such this mail is really an explanation why I am voting for an RFC defaulting to weak types, despite my misgivings with such a typing scheme. A primary appeal of this RFC is that the "strict_types" mode not only influences userland function calls, but also calls to internal functions. I really appreciate the symmetry behind this - a plain strict scalar typing proposal would only cover userland calls, while this also enforces proper type usage with internal ones. This seems very reasonable, as the same arguments in favor of strict scalar types for userland functions apply nearly identically to internal functions as well. Another advantage of this approach is that there are fewer interoperability issues between libraries using strict typing internally and external code not making use of it. A pure strict scalar typing proposal would likely cause severe integration issues between code using scalar types and code not using them at all and as such using relatively unpredictable data types. This issue will not be entirely alleviated by this proposal (primarily due to the lack of generic or semi-generic types), but it will be much more limited and libraries should be able to safely use the strict typing mode without alienating users. Lastly, I would like to talk about cognitive overhead. This RFC uses a per-file typing mode declaration and there may be concerns about having to mentally adjust to different modes being used in different files of a project. While I think this is an important concern, there are two ameliorating factors: a) It is very likely that libraries using strict scalar types will use them in the entire project rather than having a mix of different modes in different files. Similarly applications will likely also either be fully strictly typed or have clearly separated front- and backend components where only the latter uses strict scalar types. b) Within one file, this RFC actually removes mental overhead, because type declarations will behave identically for userland and internal functions. You won't have to deal with some functions being liberal and some being strict. Thanks, Nikita --f46d043894f9ee61e2050e712e46--