Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:94216 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 90851 invoked from network); 22 Jun 2016 21:21:46 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 22 Jun 2016 21:21:46 -0000 Authentication-Results: pb1.pair.com header.from=rowan.collins@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=rowan.collins@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.82.54 as permitted sender) X-PHP-List-Original-Sender: rowan.collins@gmail.com X-Host-Fingerprint: 74.125.82.54 mail-wm0-f54.google.com Received: from [74.125.82.54] ([74.125.82.54:38463] helo=mail-wm0-f54.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id F1/17-43024-9610B675 for ; Wed, 22 Jun 2016 17:21:46 -0400 Received: by mail-wm0-f54.google.com with SMTP id r201so23087211wme.1 for ; Wed, 22 Jun 2016 14:21:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=subject:references:from:to:message-id:date:user-agent:mime-version :in-reply-to:content-transfer-encoding; bh=Bnym2pp0Ws7xbKlQgjXFi19nJo/D2WsW78ElGtHxhWE=; b=T9n3/3mxs/a4TDQuZTJhZ/gOLiEm7ckzwsiNMRjIUGMngbV2XEL/ZMYYFnBqJGRSGg bDR/+YxUmgi9qxy8oE0rQZNQrUrveFzgeeey3upIC6rjbjrxHb9fyV7y9EUP92Ud+Noq eV7vjUK5Pi7G+Sd2dLGdwnGRkYwJ8j40vPwzwZgoWwzuY8++wa4KNdFx661/hYBDylCz 4WTxhGUNRUTtoZNgoSOKuHUro9qmTQ1+UU6MRLtcuXKu3l/2Hb1KuGQ6Vvil7d7vqMbX 3A9FbcKQ+LSBqHFGBZdR3rn1wh0tRpgJurx4O3kYj6d/kCiJvqVfVIgJcF64yUsZBA3l B8RA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:subject:references:from:to:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=Bnym2pp0Ws7xbKlQgjXFi19nJo/D2WsW78ElGtHxhWE=; b=WQuDJ+D1yWFxoXk+JoFHlgDDv2kpOH9UWejbHaq0T5dn+DXWVCsvCfS5dLKIN9dyK0 Km4RsHYLm4A500b35a+V/sCdbap+EmVHwYClJ9AIbpxi9q7us0vPl/j5JQNOqTQbZMi6 lYX5FaQr4pg0PZaF9VXf6OvlttHCDHkeU/sWYmsSquOIZq+cp+vdB/TuI7Ufw8O/ilxj 5gP50V0NTNrcfc9mAGrfgciUg8oT3r3ZTT8LKOklNNYKj1Qmvep5f4I2nHu3KFqAUcE4 N7e3a5Dyb4BAm46hARtuPk9b7puhQ/lxQw0h5L1OfVNCIQe6bTum7rdOywPH5DebR7CD CN6A== X-Gm-Message-State: ALyK8tLwqM/xX2q8aO8uHINAFm/8eAyOGFmOvnPwdIG7BLYjCeQuVUapqJ5Cz1cx+qFk5w== X-Received: by 10.194.72.103 with SMTP id c7mr26478438wjv.141.1466630502918; Wed, 22 Jun 2016 14:21:42 -0700 (PDT) Received: from [192.168.1.191] ([2.25.96.65]) by smtp.googlemail.com with ESMTPSA id r190sm621188wme.17.2016.06.22.14.21.41 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 22 Jun 2016 14:21:42 -0700 (PDT) References: <576A6165.8090904@lsces.co.uk> <20376416-aa04-766d-6178-189d1a088b01@gmail.com> To: PHP internals Message-ID: <411d306c-b42f-4ff4-8280-99ff357c94a1@gmail.com> Date: Wed, 22 Jun 2016 22:21:40 +0100 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.1.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] [RFC][Vote] Typed Properties From: rowan.collins@gmail.com (Rowan Collins) On 22/06/2016 20:06, Rasmus Schultz wrote: > With Dart, you have a choice - you can actually toggle whether or no > type-checks should be performed at run-time. It's probably the best of > those two references, if you're looking for inspiration for PHP. Ooh, that sounds interesting, I'll have to read up on it. :) > In PHP, every type-check is performed at run-time, and type-hints are > reflected - that's extremely important, and something Hack got > horribly wrong, as the type-hints they introduced are merely > annotations, with no run-time footprint, checked only by a static > analyzer that runs in the background; completely inconsistent with > type-checks in PHP. Hm, that's a good point, I hadn't really thought about reflection. The general direction of my thoughts was to separate the concepts of "type" and "type constraint" - e.g. no value has the type "callable", but you can already constrain a parameter with the "callable" constraint. That fits nicely with things like union types, range / subset types, etc. But the more complex those constraints could be, the harder they'd be to represent with reflection... >> Except that this proposal doesn't actually make the language consistently >> type-checked. It adds a few more special cases where you can use type hints, >> with slightly different behaviour. > That's not quite true. > > With the addition of property type-hints, the public surface through > which you interact with objects would consistently support type-hints > - so at least that makes object interactions and class design a lot > more predictable. I guess it's more a matter of opinion than truth. :) To me, a consistent typing system would be one that allows me to put type constraints wherever I have values. For instance, the current RFC excludes static properties, which as a user I consider to be close relatives of object properties, but to the engine are apparently more like plain variables. That's the kind of inconsistency that frustrates me, and makes the feature feel "half-baked", especially given that filling in the gaps is left as a "maybe, one day" rather than a "coming soon". > But at least we're finally there as far as objects, which in PHP is > probably the most important thing, as that's almost exclusively the > means by which we share code. I'm not really convinced by this. I think the type system should be a feature of every part of the language, not just where it's convenient to fit it into the engine. >>> Indeed, "gradual typing" as defined by Jeremy Siek only really makes sense >>> in the context of static analysis. > Quoting Jeremy Siek: "Gradual typing allows software developers to > choose either type paradigm as appropriate, from within a single > language" - to me, that's the important thing about gradually-typed > languages. Absolutely, we can import the goals of gradual typing. I just meant that the specific mechanism he described, of treating the "Any" type as "consistent with" every constraint, is a solution for writing static analysis tools, and doesn't help at run time, because there's never actually a value of the "Any" type. >> Taking lots of little steps "towards" a goal that we've never even properly >> defined is exactly what leads to *inconsistency* in the language. > I don't disagree with that, and I think that's a large part of PHP's problems. > > But, on the other hand, we started down the road to gradual typing > when we started adding type-hints - whether we knew what we were doing > at the time or not, the next logical step down that road is property > type-hints, which will at least clear up the number one biggest > inconsistency as far as object and class design goes. But we haven't ever decided what that road is, so how can we know what the next step is? What if we realise that the way we've implemented typed properties is completely at odds with the way we want to implement typed locals? >> I think a number of people are not "anti-type-hints", they just don't agree >> with this particular implementation. > Very possible, and they may be right - but I really hope these people > are doing something to help solve the problem, rather than simply > killing the idea and offering no alternative. I agree, but I'd urge you to practice what you preach - don't despair that this vote didn't pass, engage with the people who voted against it, and work out how to make a proposal they'll approve. There's already a majority of voters, just not the required super-majority, so I think it's pretty clear that there's an appetite for the idea, if pushed in the right direction. Regards, -- Rowan Collins [IMSoP]