Re: [RFC] [Discussion] Bound-Erased Generic Types
| From: | Seifeddine Gmati | Date: | Wed, 13 May 2026 16:26:54 +0000 |
| Subject: | Re: [RFC] [Discussion] Bound-Erased Generic Types | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-130868@lists.php.net to get a copy of this message | ||
Hi Carlos,
Thanks for the feedback.
> - It would be great to have some mention of the performance cost of this feature, both for code
> which does not use generics and for code that does use them
The design goal is zero runtime cost for code that doesn't use
generics. Code paths that don't go through turbofish should compile to
byte-identical bytecode as without the RFC. The verify opcode is only
emitted at turbofish sites, so non-generic code never executes it. The
current implementation shows around 0.1% benchmark drift in either
direction, which is at the noise floor and within the margin you'd
expect from any unrelated engine change. I haven't focused on
performance optimization yet, the goal at this stage is correctness,
not micro-tuning. However, the final number should show zero impact
for non-generic code. Code that does use turbofish pays the cost of
the arity-and-bound check at the call site, which is dominated by the
type comparison itself (the same type comparison the engine does for
any typed parameter), not by dispatch overhead.
> - It would be great to be able to see how the userland samples from Laravel, Doctrine, etc...
> would look when using this new syntax, maybe you could add a new section with this
Agreed. I'll add a parallel section showing what each example looks
like in the proposed native syntax, so readers can see the migration
directly.
Cheers,
Seifeddine.