Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:83123 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 49897 invoked from network); 18 Feb 2015 21:24:02 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 18 Feb 2015 21:24:02 -0000 Authentication-Results: pb1.pair.com header.from=leight@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=leight@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.213.52 as permitted sender) X-PHP-List-Original-Sender: leight@gmail.com X-Host-Fingerprint: 209.85.213.52 mail-yh0-f52.google.com Received: from [209.85.213.52] ([209.85.213.52:37386] helo=mail-yh0-f52.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id FA/5B-25021-1F205E45 for ; Wed, 18 Feb 2015 16:24:01 -0500 Received: by yhoa41 with SMTP id a41so2709238yho.4 for ; Wed, 18 Feb 2015 13:23:58 -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=fJ9F8HY3P+or+/Iv2AWv79dhy5KQUUT3W4+aG7ySYGs=; b=z5nL+hw/vzqoWal3uIizw9i1kX+LLwfU9SF9VJsfSKcdLsQrsazAHudDpM/vvEaiCH 0u5izk2XaDIYZrzClp8UEC9K4b54oBXmv4Lyt0bxQMvtspcPBprNr13NYMF29mwqPTQQ hw2VmpOJH7k5wfmNIkdjZAgtTgx9DnnBaLA2GbfRLtj7hBlOVZAu+alZxxyG3tDoxdW7 R7NHQi/+eX+MqHyWuKpxENAHnQf7ahX+kzlupm5MA0KyCOxxwBWhgobJC9ja4ePGrn1P 9xlj9lhtrvket0v9gIHUSurNQiqNQLYz3SSG1XsUC1zkMxdpChfPCSP7S2JOa/Ys7nPo ky1A== MIME-Version: 1.0 X-Received: by 10.53.11.76 with SMTP id eg12mr745603vdd.68.1424294638696; Wed, 18 Feb 2015 13:23:58 -0800 (PST) Received: by 10.52.179.168 with HTTP; Wed, 18 Feb 2015 13:23:58 -0800 (PST) In-Reply-To: References: Date: Wed, 18 Feb 2015 21:23:58 +0000 Message-ID: To: Anthony Ferrara Cc: "internals@lists.php.net" Content-Type: text/plain; charset=UTF-8 Subject: Re: [PHP-DEV] [RFC-Discuss] Scalar Type Declarations v0.5 From: leight@gmail.com (Leigh) On 18 February 2015 at 20:44, Anthony Ferrara wrote: > Dear Internals, > > Since the resignation of Andrea, the mixed-mode type hint (called > declaration in the proposal) proposal has been left abandoned. > Considering that the ending votes were 67/34 (66.3%) with several > no-votes being only due to reasonably minor issues with the proposal, > I would like to re-propose her RFC with three minor modifications: > > 1. declare(strict_types=1) (if used) is required to be the first > instruction in the file only. No other usages allowed. > 2. declare(strict_types=1) {} (block mode) is specifically disallowed. > 3. int typed variables can resolve a parameter type of float So > calling requiresAFloat(10) will work even in strict mode. > > As this topic has and is being discussed to death, I have put a very > large "discussion points" section: > https://wiki.php.net/rfc/scalar_type_hints_v5#discussion_points > > I would kindly ask, before replying that you check to see if your > question is answered in that list. General comments from me, as a radical strictist. No need to reply and tell me I'm "wrong", these are my opinions. > Internal Functions Like ceil() Return Unexpected Types My opinion is that functions should return sane types for their intended purpose, and functions that do not should be "fixed". > Integers Should Be Accepted For Strict float Arguments > Int->Float Exception Makes Strict Mode "Flawed" My opinion is that strict should mean strict. > Static Analysis Is Possible With Weak Declarations The advocacy of allowing `accepts_float(returns_int());` doesn't help the cause of static analysers in strict mode. > Why Not Add Support For Null? I agree a null type is pointless, however I would like to raise the discussion point of existing hinted optional parameters being allowed a default of null. i.e. fn(Obj $o = null) {} Do you think this is acceptable for any other types? I can only think of it being useful if resource and a generic object type are added. but others may disagree. (Ideally the resource type will go away over time and will be replaced with objects like GMP anyway :)) Still no mention of a way to enable strict by default. So lets try some different rationale. If I personally want to develop in strict mode, I can do that with this proposal, I can add a declare to the top of every file and be as strict as I like. However not everyone else is going to want to use my code in strict mode, so they will have to go and remove some/all of those strict declarations. (Lets take callbacks being evaluated in the context they are called rather than the one they are created in). I would like a way of enabling strict by default, immutable to scripts so that users cannot be forced into this mode, and lets the radicals and the weaklings* play together in harmony. For the rest of the RFC, I either agree with or have no strong opinions about the points raised. *it's a joke you guys.