On Thu, 24 Jan 2019 at 01:25, Dan Ackroyd <dan...@basereality.com> wrote:
> On Wed, 23 Jan 2019 at 17:25, Girgias <george.bany...@gmail.com> wrote: > > > I understand the rationale for functional programming, may I ask > > in your opinion should PHP have built-in functions for arithmetic > > operations so that it can be used in such a way without needing userland > > implementations? > > No, but only I'd much strongly prefer we have some syntax for defined > 'short closures' ala Javascript: > > $values = [1, 2, 3]; > $bar = array_map($x => $x + 1, $values); > > // $values === [2, 3, 4]; > > as those cover much more than the basic arithmetic operations, are > nice and readable after you've used them a few times. > > cheers > Dan > Ack > I didn't even know you could omit parenthesis in JS closures, the more you know. But it seems like there is already a Draft for an RFC for short closures in PHP but that one seems to have come to a halt. I've realised I didn't go through array functions so just gonna bring them up for the sake of not creating a new thread: - key_exist - alias of array_key_exist A GitHub search brings up 276 078 results where there are some userland usage but also a whole lot of unit tests usage https://github.com/search?l=PHP&p=1&q=key_exists&type=Code - pos - alias for current Can't seem to get any meaningful result by searching on GitHub as it picks up more or less anything which contains pos https://github.com/search?l=PHP&q=pos%28&type=Code - sizeof - alias of count A Github search brings up 1 617 789 results with lots of userland usage but also a bit of unit testing https://github.com/search?l=PHP&p=1&q=sizeof&type=Code And then there is *array_multisort* a function which has a signature which isn't even possible in userland code. (https://secure.php.net/manual/en/function.array-multisort.php). Other than the fact that this function's documentation isn't totally correct in my opinion I did a Github search to see if people use it. >From what I've seen in the search results [1], around 620k, it is only used in phpt unit tests and a unit test of a parser. Now, I don't think a function which doesn't follow normal function signature converntion (or isn't even possible) shouldn't really be part of the language. Moreso that it seems barely anybody uses it. What's people opinion on deprecating array_multisort ? [1] https://github.com/search?l=PHP&o=desc&p=1&q=array_multisort&s=&type=Code George P. Banyard