Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:82505 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 99641 invoked from network); 12 Feb 2015 00:11:27 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 12 Feb 2015 00:11:27 -0000 Authentication-Results: pb1.pair.com smtp.mail=sbj.ml.read@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=sbj.ml.read@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.213.181 as permitted sender) X-PHP-List-Original-Sender: sbj.ml.read@gmail.com X-Host-Fingerprint: 209.85.213.181 mail-ig0-f181.google.com Received: from [209.85.213.181] ([209.85.213.181:46416] helo=mail-ig0-f181.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id CA/B5-02515-FAFEBD45 for ; Wed, 11 Feb 2015 19:11:27 -0500 Received: by mail-ig0-f181.google.com with SMTP id hn18so478771igb.2 for ; Wed, 11 Feb 2015 16:11:24 -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:content-transfer-encoding; bh=vCAzAdiQyXDxuJ7dJXz2z8GtBa7cLAzT99zsVsFRXOc=; b=TZWquZbpyL+lSRn/vsMqreCweIEpHizP3aJ+KcFpdcaHTZcPGZ+Ill9R2qqiXdW9F/ 0OU7VQ8AAmaIYof8gzvTPWtMKZboLGgqmBe3pMpGm4jsJL+tFxbiVDbXtyYMlKzsNzrW Ikus9rdtwtlyJwcaDbZnow773yYC/+oM/SQAPiMSgoz/ducuCLSOYK6OBj+uUdFXPler 5pOPNkfW1kW5YsG083Mb+7u1Q4caUXjo8OVfze639JELvNbdafD2fpnlm//pojUGolyz IQSS+vqC/hq9ey87lEJ+NqFfhH2FsqNw+2SHZ3tFo7/lkmzfmovuMaMdxeOhYcEhlhDz s3sg== MIME-Version: 1.0 X-Received: by 10.50.142.38 with SMTP id rt6mr707057igb.17.1423699884682; Wed, 11 Feb 2015 16:11:24 -0800 (PST) Received: by 10.107.29.205 with HTTP; Wed, 11 Feb 2015 16:11:24 -0800 (PST) In-Reply-To: References: <8703B53E-2C4A-4AC6-95C4-D4F19C6D5221@ajf.me> <54DAF884.7000508@lerdorf.com> <203e611c8e0b03568a868b8d931aec37@mail.gmail.com> Date: Thu, 12 Feb 2015 01:11:24 +0100 Message-ID: To: Zeev Suraski Cc: guilhermeblanco@gmail.com, Rasmus Lerdorf , PHP Internals Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] [VOTE] Scalar Type Hints From: sbj.ml.read@gmail.com ("Sebastian B.-Hagensen") Hi, 2015-02-12 0:08 GMT+01:00 Zeev Suraski : > It gives the exact same > value from an API author=E2=80=99s point of view. But not from an api-consumers point of view. Without either introducing a new set of casting/conversion rules or changing existing behavior (**exclusively**) 'weak' typehints may be perceived as seriously crippled. Maybe up to a point where the addition of them wouldn't be justified. > But unlike the current RFC, v0.1 doesn=E2=80=99t introduce an IMHO alien = concept > into a language that considered dynamic typing to be a core principle sin= ce > its birth. It's not. PHP was always open to enforce strict typing in user created functions. If types didn't matter the way they do the current distinguishing between int/float or respectively array/stdClass/Objects shouldn't exist. But thankfully they are distinctive. The proposal offers a way to conditionally harmonize different usage patterns. (Across code bases and with internal functions) Having the ability to conditionally tighten rules in self written code but falling back to loose (in many cases good, in other cases disastrous) behavior is what modern PHP defines. To much new code already enforces strict types. Using if(!is_int) throw new WrongArgumentTypeException() or similar. The proposed RFC could unify such codebases. Having typehints in the proposed form would allow the api creator to drop most additional type checks as the method always receives what was asked for and shifts responsibility to the user. The way how an API is used would be determined by the user, allowing them to continue to use the weak behavior if they want but also offer them to enforce the rules that otherwise the api creator might force on everyone. Why don't you want to allow people to use (formerly your) language in the way they see fit as you have already given them the broader framework do to so. Having optional strict hints together with the performance improvements and the maturing php ecosystem (composer/fig/co. + enterprise-targeting frameworks) may even attract new users to php that don't want or require the mental burden or the ecosystem given by other languages(java,c#) but don't want to miss the additional safety and feeling of strict types. The other options (globally changing zpp rules and the behavior of implicit casts) sharing most of the advantages implied in the current proposal was already proposed as RFC and talked down as the BC break was considered to big. The concept behind the current RFC (not so much the syntax) is the only way to satisfy both camps without alienating a large part of the community. I'd even argue that weak hints alone wouldn't be able to reach a 2/3 majority as strict supporters (Over 1/3rd of what I've seen on this list) would need be afraid that their preference would never reach the required majority once weak hints are in. It's this proposal, semi-strict hints or changed conversion rules (The alternatives would either introduce yet another set of unconditional rules or require a considerable BC break as noted above). Everything else will either not reach the required majority or will alienate potentially large parts of the user land community (Which aren't necessarily known to the oss community, zend or similar). Thanks