Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:82971 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 55050 invoked from network); 17 Feb 2015 15:22:26 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 17 Feb 2015 15:22:26 -0000 Authentication-Results: pb1.pair.com smtp.mail=zeev@zend.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=zeev@zend.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain zend.com designates 209.85.223.181 as permitted sender) X-PHP-List-Original-Sender: zeev@zend.com X-Host-Fingerprint: 209.85.223.181 mail-ie0-f181.google.com Received: from [209.85.223.181] ([209.85.223.181:36142] helo=mail-ie0-f181.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 61/8D-19463-0BC53E45 for ; Tue, 17 Feb 2015 10:22:25 -0500 Received: by ierx19 with SMTP id x19so41610533ier.3 for ; Tue, 17 Feb 2015 07:22:21 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:references:in-reply-to:mime-version :thread-index:date:message-id:subject:to:cc:content-type; bh=v6+GPbv5UQIGIpdzeysqIAibBJNspficDTIDZa+r8vI=; b=TKp97p5WVdPjW0E2FqGXBwHYPrJB1EFIY7+N9Bejh+DJz45ElXEqkFzwaBnc5PEybU k0V7W7GfEO0pmXDO9Ffhp++mrSUO+9OvMDjPd/ohacKgtVQ0Pa4I238831RWlFYN7rS3 mvRLrJiLjeHpVF06L+ggJ6dEST33CLl0yVy8M4s/nCJqwPbNFaJcCb2PhZxcVRN9dmyw Kn8LAy7jbusU2hbs2GavlJFijvoiIZvplVE+QQhDQIXydFjM4gQWxPuzyFL8HLT60NmP FoEvbMDocnT2odaDcHfxDqfUz4ngLkwksRrUv8LralwTehJsc9TcDwZtbX6pR9yEhfb2 qVNg== X-Gm-Message-State: ALoCoQmG5gwDjE8BXGQXm5agHEIrS2GcEmC4txV4fQP+n7g8YPDhY+Myx0ZjXuVM/Q1aGbHv2K5GfL9VoIKvQWidHqpR3ePAMkI8J2u+GCgQ1uEst8HE0W2UfSZcH5z11peLuueThuBWuhZ4qWg+KHVgRkOYSxmleg== X-Received: by 10.43.103.8 with SMTP id dg8mr34893267icc.18.1424186540919; Tue, 17 Feb 2015 07:22:20 -0800 (PST) References: <011801d04a07$83ab1c00$8b015400$@php.net> <016f01d04a3a$e9183220$bb489660$@php.net> <022801d04ab1$4a0c47d0$de24d770$@php.net> <1913e09d7f52541901d8574d2080a63f@mail.gmail.com> In-Reply-To: MIME-Version: 1.0 X-Mailer: Microsoft Outlook 14.0 Thread-Index: AQGD0sLDaA+/0NIeBlQhQC5OtPA/xwHih9+6AanvcsEBj7eMCwEU0CpMAs0H7+gBDwGZjwJNu28fAWzN03+dH6T+8A== Date: Tue, 17 Feb 2015 17:22:19 +0200 Message-ID: To: Andrey Andreev Cc: francois@php.net, Sara Golemon , PHP internals Content-Type: text/plain; charset=UTF-8 Subject: RE: [PHP-DEV] Reviving scalar type hints From: zeev@zend.com (Zeev Suraski) > -----Original Message----- > From: Andrey Andreev [mailto:narf@devilix.net] > Sent: Tuesday, February 17, 2015 4:49 PM > To: Zeev Suraski > Cc: francois@php.net; Sara Golemon; PHP internals > Subject: Re: [PHP-DEV] Reviving scalar type hints > > Hi, > > On Tue, Feb 17, 2015 at 3:33 PM, Zeev Suraski wrote: > > I agree. It's more of a question of eliminating potentially dangerous > > conversions than just being lossless. > > > > Agreed as well. However, while bool -> int conversion one of the reasons > why many people want strict type-hints, it also often makes sense and is > quite widespread. There's no silver bullet for that problem. I'm not sure we need a silver bullet. If the conversion and acceptance rules are clear and reasonable, it's an entirely valid outcome that in cases where both int and bool are equally acceptable, you won't use a type hint but rather explicitly cast to int inside the function. > But is it the best solution? The dual-mode approach was suggested because > there is need and demand for *two* kinds of type-hinting. Most of the > controversy and criticism came from the fact that introduces a switchable > mode, while most of the praise received was due to somebody finally > proposing *both* solutions at the same time. Every option has pros and cons. Since it's clear beyond a reasonable doubt that we can't all agree on purely weak type hints and equally on purely strict type hints, it becomes a question of what is the right compromise. Adding both - which at least from my point of view has major drawbacks (too prominent zval.type exposure; complexity of two systems; internal functions issue). Creating something in between that would handle most if not all of the use cases the strict camp brought up, while not (IMHO) overly focusing on zval.type and making things a lot more noisy/complex for built-in functions - is a better direction, whose advantage - I think - outweigh its disadvantages. > > If we still see that employing the strict(er) rules is very noisy with > > internal functions, a more appropriate option may be introducing new > > types into ZPP, that would correspond to the new rules we introduce in > > the userland type hints, and requiring extension authors to explicitly > > move to them where they believe it's appropriate. That will allow > > extension authors to make their choice regarding their APIs, similarly > > to the process that will happen in userland. > > > > And that brings us back to square one ... Expose only 1 tool to userland, > but > then give two options to the much less-populated crowd of extension > developers. That doesn't make sense to me. First, let us hope that the situation will be much better to a level that we don't need to go in that direction :) But that said, I don't quite see it in the same way. Internal functions already commonly use a lot more advanced type checking than is commonly found in userland functions. Functions that behave differently depending on the type of argument you pass, on the number of arguments, etc. While technically it's possible to achieve in userland, it's a lot less common. So while I do see an issue here, I don't think it's *that* bad if it has to come to that. Unless we find out our rules work nicely out of the box for internal functions (which I'm still somewhat hopeful for) - there's no way to reconcile the fact that internal functions come with this long history of having detailed type data, while userland functions do not... Zeev