Re: [PHP-DEV] Proposal for a new array function

2016-02-09 Thread Matthew Setter
Thanks kindly for the rapid and very helpful feedback. I'm going over it today and will collate it and think over it further. Given that the feedback's been so constructive and positive, I'll be getting started on an RFC over the next day or so. Matt -- Kind regards, *Matthew Setter*

Re: [PHP-DEV] Proposal for a new array function

2016-02-09 Thread Lester Caine
On 09/02/16 02:52, Yasuo Ohgaki wrote: > Hi, > > On Tue, Feb 9, 2016 at 1:03 AM, Kinn Julião wrote: >> And what's wrong with doing: >> https://gist.github.com/kinncj/566bbc019be5707b01f2 ? > > Perfectly ok to me while it would be slower. > > BTW, it's easy and quick to detect

Re: [PHP-DEV] Proposal for a new array function

2016-02-09 Thread guilhermebla...@gmail.com
My personal take on this: Let's add just more 1 function over a 9 function's array API, because I want to optimize 3 lines in my PHP code, and language lack of Generics while we still refuse to carefully think about a proper OO Collection API. Regards, On Tue, Feb 9, 2016 at 6:19 AM,

Re: [PHP-DEV] Proposal for a new array function

2016-02-09 Thread Rowan Collins
guilhermebla...@gmail.com wrote on 09/02/2016 15:41: My personal take on this: Let's add just more 1 function over a 9 function's array API, because I want to optimize 3 lines in my PHP code, and language lack of Generics while we still refuse to carefully think about a proper OO Collection

Re: [PHP-DEV] Proposal for a new array function

2016-02-08 Thread Kinn Julião
On Mon, Feb 8, 2016 at 10:54 AM, Lester Caine wrote: > On 08/02/16 15:42, Pierre Joye wrote: > >> I want to propose a new PHP array method, called has_numeric_keys (or > >> > something similar/better), that would have the following method > signature: > >> > > >> > bool

Re: [PHP-DEV] Proposal for a new array function

2016-02-08 Thread Eugene
On Mon, Feb 8, 2016 at 3:32 PM, Matthew Setter wrote: > I want to propose a new PHP array method, called has_numeric_keys (or > something similar/better), that would have the following method signature: > > bool has_numeric_keys(array $array) > > The reason for it is to

Re: [PHP-DEV] Proposal for a new array function

2016-02-08 Thread Lester Caine
On 08/02/16 15:42, Pierre Joye wrote: >> I want to propose a new PHP array method, called has_numeric_keys (or >> > something similar/better), that would have the following method signature: >> > >> > bool has_numeric_keys(array $array) > I have no strong opinion on it but I wonder if it should

Re: [PHP-DEV] Proposal for a new array function

2016-02-08 Thread Rowan Collins
Matthew Setter wrote on 08/02/2016 14:32: I want to propose a new PHP array method, called has_numeric_keys (or something similar/better), that would have the following method signature: bool has_numeric_keys(array $array) I like it. I also suspect it could be implemented very efficiently in

Re: [PHP-DEV] Proposal for a new array function

2016-02-08 Thread Rowan Collins
François Laupretre wrote on 08/02/2016 15:44: For a better consistency, may I suggest a function that would allow to know whether array keys are all numeric, all strings, or mixed. Something like array_keys_type() returning one of 3 predefined constants : ARRAY_KEYS_NUMERIC, ARRAY_KEYS_STRING,

Re: [PHP-DEV] Proposal for a new array function

2016-02-08 Thread Rowan Collins
Kinn Julião wrote on 08/02/2016 16:05: That's the nice thing about userland... you are giving them ability to implement what they want! `array_filter([...], 'is_int', ARRAY_FILTER_USE_KEY)` does the job as the others... don't think having a new function would prevent this. It does the job, but

Re: [PHP-DEV] Proposal for a new array function

2016-02-08 Thread Cesar Rodas
On 2/8/16 2:04 PM, Eugene wrote: > On Mon, Feb 8, 2016 at 3:32 PM, Matthew Setter wrote: > >> I want to propose a new PHP array method, called has_numeric_keys (or >> something similar/better), that would have the following method signature: >> >> bool

Re: [PHP-DEV] Proposal for a new array function

2016-02-08 Thread Yasuo Ohgaki
Hi, On Tue, Feb 9, 2016 at 1:03 AM, Kinn Julião wrote: > And what's wrong with doing: > https://gist.github.com/kinncj/566bbc019be5707b01f2 ? Perfectly ok to me while it would be slower. BTW, it's easy and quick to detect array is real array with PHP7. It would be handy if

Re: [PHP-DEV] Proposal for a new array function

2016-02-08 Thread Pierre Joye
Hi, On Feb 8, 2016 10:00 PM, "Matthew Setter" wrote: > > I want to propose a new PHP array method, called has_numeric_keys (or > something similar/better), that would have the following method signature: > > bool has_numeric_keys(array $array) I have no strong opinion on

[PHP-DEV] Proposal for a new array function

2016-02-08 Thread Matthew Setter
I want to propose a new PHP array method, called has_numeric_keys (or something similar/better), that would have the following method signature: bool has_numeric_keys(array $array) The reason for it is to check if the array passed to it only had numeric keys. Why this method, when you could do

Re: [PHP-DEV] Proposal for a new array function

2016-02-08 Thread Matt Prelude
On 08/02/16 17:36, Markus Fischer wrote: Hi, On 08.02.16 18:06, Cesar Rodas wrote: return array_keys($arr) !== range(0, count($arr) - 1); `array_keys($array) === range(0, count($array)-1)` That approach would fall flat when the numeric keys are not consecutive: $array = [1=>"a", 3=>"b"];

Re: [PHP-DEV] Proposal for a new array function

2016-02-08 Thread Matt Prelude
Hi, I want to propose a new PHP array method, called has_numeric_keys (or something similar/better), that would have the following method signature: bool has_numeric_keys(array $array) The reason for it is to check if the array passed to it only had numeric keys. Why this method, when you

Re: [PHP-DEV] Proposal for a new array function

2016-02-08 Thread Kinn Julião
On Mon, Feb 8, 2016 at 12:53 PM, Larry Garfield wrote: > On 2/8/16 11:46 AM, Kinn Julião wrote: > >> On Mon, Feb 8, 2016 at 11:38 AM, Rowan Collins >> wrote: >> >> Kinn Julião wrote on 08/02/2016 16:05: >>> >>> That's the nice thing about

Re: [PHP-DEV] Proposal for a new array function

2016-02-08 Thread Markus Fischer
Hi, On 08.02.16 18:06, Cesar Rodas wrote: >>> return array_keys($arr) !== range(0, count($arr) - 1); > > `array_keys($array) === range(0, count($array)-1)` That approach would fall flat when the numeric keys are not consecutive: $array = [1=>"a", 3=>"b"]; Disclaimer: AFAIK complete goal of

Re: [PHP-DEV] Proposal for a new array function

2016-02-08 Thread Kinn Julião
On Mon, Feb 8, 2016 at 11:38 AM, Rowan Collins wrote: > Kinn Julião wrote on 08/02/2016 16:05: > >> That's the nice thing about userland... you are giving them ability to >> implement what they want! >> `array_filter([...], 'is_int', ARRAY_FILTER_USE_KEY)` does the job

Re: [PHP-DEV] Proposal for a new array function

2016-02-08 Thread Larry Garfield
On 2/8/16 11:46 AM, Kinn Julião wrote: On Mon, Feb 8, 2016 at 11:38 AM, Rowan Collins wrote: Kinn Julião wrote on 08/02/2016 16:05: That's the nice thing about userland... you are giving them ability to implement what they want! `array_filter([...], 'is_int',