Re: [RFC][Vote] Typed Properties

From: Date: Wed, 22 Jun 2016 17:44:37 +0000
Subject: Re: [RFC][Vote] Typed Properties
References: 1 2 3 4 5 6 7 8  Groups: php.internals 
Request: Send a blank email to internals+get-94211@lists.php.net to get a copy of this message
On 22/06/2016 16:58, Rasmus Schultz wrote:
On Wed, Jun 22, 2016 at 11:59 AM, Lester Caine <lester@lsces.co.uk> wrote: Having worked in other gradually-typed languages like Dart and Typescript
Out of curiosity, do these languages perform the type analysis at compilation, or at run-time? I'm trying to collate some examples of how other languages have approached the problem.
PHP feels crippled on this point - it's gradually-typed, but inconsistently so, and inconsistency is the worst kind of evil you can have in any programming language.
I absolutely agree, we need a plan for how to introduce a consistent gradual typing system. But this RFC is not that plan.
The learning curve for new users isn't increased by the introduction of property type-hints, it's *decreased*
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. To carry on your imagined conversation: - ooh, I can type-hint properties now! - wait, what does this error mean? why would I not be able to assign this property by reference? - oh, because the variable holding the reference would have to be type-hinted; how do I do that? - oh, I can't...
and then in addition they need to go and learn about php-doc and offline inspection tools and IDEs and so forth.
Interestingly, this is the direction that Hack and Python have both apparently chosen to enshrine - the syntax is baked into the language, but not actually enforced by the standard compiler or run-time in any way. Indeed, "gradual typing" as defined by Jeremy Siek only really makes sense in the context of static analysis.
Sorry, for the rant, but anti-type-hints is just anti-consistency. We have type-hints, now let's please take another step towards finishing the job!
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 think a number of people are not "anti-type-hints", they just don't agree with this particular implementation. Regards, -- Rowan Collins [IMSoP]

« previous php.internals (#94211) next »