> Le 1 oct. 2023 à 14:35, Saki Takamachi <s...@sakiot.com> a écrit : > > Hi, internals > > I would like to start the discussion for my RFC "Adding bcround, bcfloor and > bcceil to BCMath”. > https://wiki.php.net/rfc/adding_bcround_bcfloor_bcceil_to_bcmath > > Regards. > > Saki > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: https://www.php.net/unsub.php >
Hi, Some remarks about the paragraph “Backward Incompatible Changes” > These are new features and do not break existing functionality. > > If I had to point out my concerns, I would say that code that satisfies the > following conditions will cause an error to occur. > > * A situation where the user has defined a function with the same name, such > as bcround() This is a real concern. I have personally defined a `bcround()` global function because I needed such a functionality. A quick search on GitHub shows that I am not alone: https://github.com/search?q=bcround+language%3Aphp&type=code > > * And, the existence of the function is not checked in advance. If the existence of the function is checked in advance, the BC risk is worst, because they cannot have known whether the signature and semantics of the function you will introduce will be compatible with the one they have defined. In case of mismatch the eventual breakage could be more difficult to notice and trace back. Note in particular this SO question: https://stackoverflow.com/questions/231057/how-to-round-ceil-floor-a-bcmath-number-in-php, where the second answer has a different rounding mode on halves than the first and third answers. Fortunately, the few examples I have seen don’t foolishly guard the definition with `if (!function_exists(...))`, so that there will be a hard break when upgrading PHP (static error: function already defined), and they’ll have to decide explicitly what to do. In my case, I’ll wait until this RFC is accepted, then (and only then) I’ll decide what to do depending on whether my version of `bcround()` is compatible with yours (either rename or `function_exists()` guard). > > However, I do not think it is necessary to consider these matters. I think that it is necessary to acknowledge that there will be breakage for some people, and to decide explicitly whether this breakage is acceptable. (I think it is.) —Claude