Re: Split as an alias to explode
| From: | Christoph M. Becker | Date: | Sat, 16 Aug 2025 09:16:40 +0000 |
| Subject: | Re: Split as an alias to explode | ||
| References: | 1 2 3 4 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-128489@lists.php.net to get a copy of this message | ||
On 15.08.2025 at 23:47, Paul Dragoonis wrote:
> On Fri, Aug 15, 2025, 10:30 PM mickmackusa <mickmackusa@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