Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:83795 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 67462 invoked from network); 25 Feb 2015 15:13:49 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 25 Feb 2015 15:13:49 -0000 Authentication-Results: pb1.pair.com header.from=dmitry@zend.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=dmitry@zend.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain zend.com designates 209.85.220.179 as permitted sender) X-PHP-List-Original-Sender: dmitry@zend.com X-Host-Fingerprint: 209.85.220.179 mail-vc0-f179.google.com Received: from [209.85.220.179] ([209.85.220.179:49487] helo=mail-vc0-f179.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 89/25-62407-CA6EDE45 for ; Wed, 25 Feb 2015 10:13:48 -0500 Received: by mail-vc0-f179.google.com with SMTP id hy4so1546167vcb.10 for ; Wed, 25 Feb 2015 07:13:45 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=0TxWl5Uhpa3ZmDjj28ODGQ2EYVQG+2ktaiZ+w0K9xBg=; b=DElT1oaL5oZLiKReRy63fIb0FHmlUiHuGtDFa204S0bKrjcWvQboo5eZaCuk0vl7Pz HtgwSqO3NUH8MQCg0cghvcR8DGSwOKrF6xpJQ5yRDAlehjPqG8wNxu2RtP9CHTQ3esQD s92coaIGJ1xJ6eUPSVzGZkfZxSOY0ma2qdLh+CmD8vo48O+xqmteF0h83Oq1efUH1ROB 1Q1mFgCl6uIhRg3ZzFfZU4O6ClyeUMT4l3cTEgYL/2QxAidnm/0PfUE5xbsvXgp4MLRp wXjIT5IBmDqE8Wwv4+87B6h+PC6wvQtetgS3ZrYhHm32T2d0cFKgIpu29JHcXwPf4Cf0 outw== X-Gm-Message-State: ALoCoQn/H+/kASWyAthSdxtBlstSmFhoGkN0ANne7q/QHfnZGHSqPTl/QnfSODx2PDfhYk0UQzx6Z+T3xmfPVA/jHgdbQCKrDQNJl7KVTt5H6NGm+wH9ohjbqiHoaXi7aiOeFhLEoR70SG3QDLRVw/+30MiUx69e6w== MIME-Version: 1.0 X-Received: by 10.52.103.75 with SMTP id fu11mr4313469vdb.5.1424877224937; Wed, 25 Feb 2015 07:13:44 -0800 (PST) Received: by 10.52.113.231 with HTTP; Wed, 25 Feb 2015 07:13:44 -0800 (PST) In-Reply-To: References: Date: Wed, 25 Feb 2015 19:13:44 +0400 Message-ID: To: Anthony Ferrara Cc: "internals@lists.php.net" Content-Type: multipart/alternative; boundary=047d7b86d990d7715c050feb1432 Subject: Re: [PHP-DEV] Re: [RFC-Discuss] Scalar Type Declarations v0.5 From: dmitry@zend.com (Dmitry Stogov) --047d7b86d990d7715c050feb1432 Content-Type: text/plain; charset=UTF-8 On Wed, Feb 25, 2015 at 6:03 PM, Anthony Ferrara wrote: > 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. > It's also a reason why others may vote against the whole and we will get nothing. > > I'd rather keep the vote about one thing, and one thing only. > I got you. All or nothing :) > > > 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. > I post the links to the important changes above. Even JITed code will have to implement these additional checks in run-time. > 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. > It's not so simple, because you don't know the function at compile-time. > > > > > - 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. > Not all resources may be replaced with objects. > > - 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); > right. but this is a smaller break. > 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). > this is your opinion. I have another. I don't know opinion of others. Why not to 50/50 voting. If you don't do it, may be I should do. Thanks. Dmitry. > > Anthony > --047d7b86d990d7715c050feb1432--