> Le 16 août 2025 à 11:16, Christoph M. Becker <cmbecke...@gmx.de> a écrit : > > On 15.08.2025 at 23:47, Paul Dragoonis wrote: > >> On Fri, Aug 15, 2025, 10:30 PM mickmackusa <mickmack...@gmail.com> wrote: >> >>> I don't see any benefit to re-adding split() to the language. Why create >>> more keywords for the sake of a function name with fewer characters? Code >>> golfing isn't a goal of the language. >> >> Ancient history aside and forward looking; JavaScript took a huge boom in >> recent years and overtook PHP in areas of new adoption and code DX >> >> Making it a smoother transition for JS devs to hop back on the modern PHP >> train is in all our shared interest in terms of user base, and split() >> would help this. >> >> So why not? > > Because it would still be rather confusing to JavaScript developers who > are used to > > str.split(separator) > > and now would have to deal with > > split(separator, str) > > In my opinion, the difficulty is not the name the name of the function, > but rather that it is a function and not a method. Having a different > function name, can even be slightly beneficial to stress that difference. > > Christoph
Apart from the order of arguments, there is another confusing difference between the PHP function and the JavaScript one. Both accept an additional parameter named `limit`, with subtly but fundamentally different semantics, and you have to read very carefully the documentation (or test the function) to understand it. (And to be clear, I am *not* speaking of the fact that PHP accept a “negative” limit: that one is not subtle enough.) The difference of naming is probably the least problematic difference, and attempting to reduce that specific difference without regard to the other ones, won’t reduce confusion. —Claude