Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:83789 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 58642 invoked from network); 25 Feb 2015 15:03:14 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 25 Feb 2015 15:03:14 -0000 Authentication-Results: pb1.pair.com smtp.mail=ircmaxell@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=ircmaxell@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.217.172 as permitted sender) X-PHP-List-Original-Sender: ircmaxell@gmail.com X-Host-Fingerprint: 209.85.217.172 mail-lb0-f172.google.com Received: from [209.85.217.172] ([209.85.217.172:38029] helo=mail-lb0-f172.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 98/23-62407-034EDE45 for ; Wed, 25 Feb 2015 10:03:13 -0500 Received: by lbiz11 with SMTP id z11so4421585lbi.5 for ; Wed, 25 Feb 2015 07:03:09 -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=BSBGCc+jV6Z9GZZJsAF+SvP1SfxxcKw3Bj6e6B/sugw=; b=Bd2s8e8inbD/MaFulP3xR356gSUdhSORVw21RV8h7xXA9Q0i8+XutZA7dHBcLHbdtD 8Qb2HzB3KhGxjO3gObA2wSoqp8HrP0rTBmdqtztgNOASokbmqNcJAXz8FxLoUp5rF/KO vCUz4x2zQlZbqkOB/TnORSrhgrp+XusFCHA/5t8S+ZxQB3MaEHil8lxIB2LGTntOiaju 1tAOMaTcM3OxuLJNGMIhEl7ucklnrEfzgotmBiOouyIuyFvh/4kzxXVGJ0Lxn/bLQ8X2 HtEEtb3QpeYVOy4lB5WagS8k3FAImpaMeL6/EpLi3FtfVSnKLmg8ZyEHLvbtWIe5hbw+ 4Rxw== MIME-Version: 1.0 X-Received: by 10.153.5.11 with SMTP id ci11mr2957159lad.95.1424876589606; Wed, 25 Feb 2015 07:03:09 -0800 (PST) Received: by 10.25.43.9 with HTTP; Wed, 25 Feb 2015 07:03:09 -0800 (PST) In-Reply-To: References: Date: Wed, 25 Feb 2015 10:03:09 -0500 Message-ID: To: Dmitry Stogov Cc: "internals@lists.php.net" Content-Type: text/plain; charset=UTF-8 Subject: Re: [PHP-DEV] Re: [RFC-Discuss] Scalar Type Declarations v0.5 From: ircmaxell@gmail.com (Anthony Ferrara) Dmitry, On Wed, Feb 25, 2015 at 7:19 AM, Dmitry Stogov wrote: > Hi Anthony, > > Few notes: > > - first of all, it would be great to split the voting questions: 2/3 - > implement scalar type hinting + 1/2 - in addition add strict type hinting as I've mentioned this a few times, but I disagree with that concept. I believe RFCs should fully describe a feature and should be voted on in whole. Additionally, it presents a problem when it comes to voting. What if a person wants strict types. And it looks like it's overall going to pass, but that weak types is winning. What's the best way for them to vote? No. For the entire proposal. I'd rather keep the vote about one thing, and one thing only. > you propose. I think, the concept of run-time declare() switch is not > designed well. It just affects VM and JITed code in negative way, because in > each function we will have to handle both options > https://github.com/ircmaxell/php-src/compare/scalar_type_hints_v5#diff-3054389ad750ce9a9f5895cd6d27800fR3762 > and also set additional flag on each call > https://github.com/ircmaxell/php-src/compare/scalar_type_hints_v5#diff-3054389ad750ce9a9f5895cd6d27800fR2802 What negative way is that? It's a clearly defined switch, kept in a clearly defined place. And considering it's a purely compile time construct, I fail to see how it could possibly affect either the VM or JITed code in a negative way. Heck, if we really wanted to, we could compile a separate ZEND_DO_FCALL opcode for strict types: ZEND_DO_STRICT_FCALL, which hard-codes the strict data. > > - resource type hint may be useful in the same way as all other types The problem here is typing on a resource doesn't give you enough information to be "safe": function foo(resource $bar): string { return fread($bar); } foo(mysql_connect(...)); I think a longer-term plan to replace (transparently) resources with objects would be far more beneficial. > - it may make sense not to disable bool/int/float/string classes at all. we > may just don't allow them in type hints. This will break less applications. It'll still break applications, because you can no longer do: function foo(String $string) {} foo(new String); I think leaving the ability to create a class named "string" while at the same time removing the ability to type against it is not only weird, but definitely not something I think we should do (it's just way to inconsistent). Anthony