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 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.

Ilija

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

Reply via email to