Hi Ilija

> On 17 Sep 2020, at 19:01, Ilija Tovilo <tovilo.il...@gmail.com> wrote:
> 
> Hi Brent
> 
>> Today I'd like to hear your thoughts on what might be a controversial topic, 
>> though I think it's worth having this discussion. I want to make the case 
>> for adding generic syntax, without actually enforing any additional type 
>> checks at runtime. Please hear me out.
> 
> I think having the option to omit runtime type checks could be
> valuable even for non-generic code. If your own internal classes all
> use static analysis the chance of passing a wrong type is pretty low.
> This would probably have to be on a per class or even per function
> basis as you can't reason about other people's code.

I agree, if there's enough interest in this, we might need to consider the 
scope of one or several RFCs.

> 
> I do think we need some form of generic runtime check. If we don't,
> how generics work is completely open to interpretation. Static
> analysis tools copy the behavior of PHP. If PHP has no behavior in
> this regard tools will deviate and generics won't have any real
> meaning at all. There are many nuances to generics (ask Matthew who
> wrote Psalm), we shouldn't underestimate that. With a hybrid approach
> we could also do full type checking in testing environments and
> disable it in more performance critical situations with more
> confidence.

Larry also shared this concern, and I agree that it's important to at least 
have an official spec from the PHP project. Whether part of it should be 
enforced at runtime is up for debate, but it's definitely important.

> 
> Ilija
> 
> --
> PHP Internals - PHP Runtime Development Mailing List
> To unsubscribe, visit: https://www.php.net/unsub.php
> 

Kind regards
Brent

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: https://www.php.net/unsub.php

Reply via email to