Re: [PHP-DEV] [DISCUSS] Should RFCs for new functions include a userland polyfill/reference implementation?
سپهر محمودی <[email protected]>
| Newsgroups | gmane.comp.php.devel |
|---|---|
| Message-ID | <CA+Jcf5sxUjRxPAKq-LEzxmaiK4=E+xQB8dNoQ-T5F4OVexKs+A@mail.gmail.com> |
در تاریخ پنجشنبه ۲۷ اوت ۲۰۲۶، ۲۰:۰۲ Nicolas Grekas < [email protected]> نوشت: > Hi Sepehr > > Le mar. 25 août 2026 à 13:21, سپهر محمودی <[email protected]> a > écrit : > >> Hi internals, >> >> While reviewing various RFCs that introduce new functions, I noticed an >> inconsistency: some authors include a userland polyfill (reference >> implementation) in their RFCs, while others do not. >> >> I wanted to open a discussion on whether we should strongly encourage RFC >> authors to provide a PHP userland implementation when proposing new >> standard library functions, **where technically feasible**. >> >> Of course, I understand that this isn't possible for every new >> function—especially those that interact with low-level OS APIs, memory >> management, or internal engine features. However, for functions dealing >> with arrays, strings, math, or general logic, I believe this has a couple >> of major benefits: >> >> 1. It clarifies the exact intended behavior, including edge cases and >> type coercions, making the proposal easier to understand without diving >> into the C implementation. >> 2. It immensely helps the community (e.g., the Symfony polyfill team) to >> quickly and accurately port the function to older PHP versions once the RFC >> is accepted. >> >> Should we consider adding this as a standard recommendation (e.g., >> "Reference Implementation") in the official RFC template for applicable >> functions? >> >> I would love to hear your thoughts on this. >> >> Best regards, >> Sepehr >> >> > > In case you didn't know, every polyfill-able feature ends up eventually in > one of the symfony/polyfill-* packages, all centralized in the > https://github.com/symfony/polyfill monorepo. > > In my experience, this works quite well and I wouldn't require RFCs to > ship a polyfill: authors should be focused on the C implementation. The PHP > polyfill is not always trivial to achieve, and polyfills proposed in RFCs > don't necessarily end up being the ones shipped via symfony/polyfill, eg > because edge cases or perf improvements. > Polyfill needs a separate workflow. > > Cheers, > Nicolas > ----- Thanks Nicolas, that makes total sense. I will focus entirely on the C implementation.