You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: source/_posts/2025-08-05-compile-generics.md
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -13,11 +13,11 @@ published_at: 04 August 2025
13
13
14
14
One of the most sought-after features for PHP is Generics: The ability to have a type that takes another type as a parameter. It's a feature found in most compiled languages by now, but implementing generics in an interpreted language like PHP, where all the type checking would have to be done at runtime, has always proven Really Really Hard(tm), Really Really Slow(tm), or both.
15
15
16
-
But, experimentation by the PHP Foundation's dev team suggests we may be able to get 80% of the benefit for 20% of the work. Is that enough?
16
+
But, experimentation by Gina from the PHP Foundation's dev team suggests we may be able to get 80% of the benefit for 20% of the work. Is that enough?
17
17
18
18
## The short, short version
19
19
20
-
We believe it's possible to implement generics on only interfaces and abstract classes, which would offer a large chunk of the benefit of generics but avoid most of the pitfalls.
20
+
Gina and Larry believe it's possible to implement generics on only interfaces and abstract classes, which would offer a large chunk of the benefit of generics but avoid most of the pitfalls.
21
21
22
22
In particular, interfaces and abstract classes could declare that they need one or more types specified:
23
23
@@ -365,7 +365,7 @@ This work is still experimental. As noted above, there's a few additional featu
365
365
366
366
The Foundation, of course, wants to be respectful of the time of our development team, the time of the many RFC reviewers, and the pocketbooks of our generous sponsors. Foundation staff have already sunk quite a bit of time into the question of generics. Before we sink more time into it, we want to ask the community (and PHP Internals especially)... Is it worth it?
367
367
368
-
Would a partial-generics approach like that described here be acceptable? Even if it may not be possible to go all the way to full generics, would "compile time-only generics" be a big enough win to justify spending more time on it? Our team thinks it is, but PHP is larger than our team, so we want to get feedback from the broader community.
368
+
Would a partial-generics approach like that described here be acceptable? Even if it may not be possible to go all the way to full generics, would "compile time-only generics" be a big enough win to justify spending more time on it? Gina from The PHP Foundation team thinks it is, but PHP is larger than just our team, so we want to get feedback from the broader community.
369
369
370
370
**Would you support (and vote in favor of) compile-time-only generics as described here?**
0 commit comments