On Thu, 17 Sep 2020 at 20:25, Levi Morrison via internals <
internals@lists.php.net> wrote:

>
> In summary:
> - Checked at run-time (and probably also compile-time when possible):
> reified generics.
> - Checked only at compile-time and thrown away at run-time: erased
> generics.
> - Not checked at all: ____?. Maybe we can call them "ignored generics"?
>


I think this is making the common assumption that "official" static
analysis and compilation are necessarily the same process, but the compiler
itself only needs to "understand" enough to choose a target representation;
running other analysis at the same time is just a choice for programmer
convenience.

My understanding is that in reality there are three stages:

1) Static analysis: checks may be made whether erasing or reifying, because
erasure hasn't happened yet.
2) Compilation: erased generics are converted to non-generic types; reified
generics are compiled to a representation available at run-time
3) Run-time: reified generics have run-time behaviour; erased generics
aren't ignored, they simply don't exist because the compiler already erased
them

In PHP, we currently have a compile step, run on-demand, but do not have an
official static analysis step. I have said before that in order to make the
type system richer without sacrificing run-time performance, we need to
consider having such an official tool. That could be run automatically
alongside the existing on-demand compilation; it could be entirely manual
as a separate tool; or it could be combined with a new, manually executed
compiler or transpiler. I believe there is precedent for all of these
approaches.

Regards,
-- 
Rowan Tommins
[IMSoP]

Reply via email to