[PHP-DEV] Consolidation of Traversable and array operations

2015-07-15 Thread Tjerk Meesters
Hi! A few weeks ago I resurrected a two year old proposal for adding two array functions, namely array_every() and array_some(), modelled after their JavaScript equivalent. https://github.com/php/php-src/pull/1385 The most notable comment was that it would be nice to support Traversable as well

Re: [PHP-DEV] Consolidation of Traversable and array operations

2015-07-15 Thread Michael Wallner
On 15/07/15 13:28, Tjerk Meesters wrote: > Hi! > > A few weeks ago I resurrected a two year old proposal for adding two array > functions, namely array_every() and array_some(), modelled after their > JavaScript equivalent. > > https://github.com/php/php-src/pull/1385 > > ... > > Let me know wh

Re: [PHP-DEV] Consolidation of Traversable and array operations

2015-07-15 Thread Johannes Schlüter
Hi, On Wed, 2015-07-15 at 11:28 +, Tjerk Meesters wrote: > The most notable comment was that it would be nice to support Traversable > as well as arrays; instead of only supporting this for my own functions, > I've generalised this so that other functions can take advantage of this as > well.

Re: [PHP-DEV] Consolidation of Traversable and array operations

2015-07-15 Thread Julien Pauli
On Wed, Jul 15, 2015 at 3:43 PM, Johannes Schlüter wrote: > Hi, > > On Wed, 2015-07-15 at 11:28 +, Tjerk Meesters wrote: > > The most notable comment was that it would be nice to support Traversable > > as well as arrays; instead of only supporting this for my own functions, > > I've generali

Re: [PHP-DEV] Consolidation of Traversable and array operations

2015-07-15 Thread Levi Morrison
On Wed, Jul 15, 2015 at 8:31 AM, Julien Pauli wrote: > On Wed, Jul 15, 2015 at 3:43 PM, Johannes Schlüter > wrote: > >> Hi, >> >> On Wed, 2015-07-15 at 11:28 +, Tjerk Meesters wrote: >> > The most notable comment was that it would be nice to support Traversable >> > as well as arrays; instead

Re: [PHP-DEV] Consolidation of Traversable and array operations

2015-07-15 Thread Rowan Collins
On 15 July 2015 20:39:05 GMT+01:00, Levi Morrison wrote: >Do note that the union types RFC would also alleviate some of this >pain for user-land functions, since `array | Traversable` would cover >the required access pattern. I think this is a superior approach >myself, but I may be a bit biased a

Re: [PHP-DEV] Consolidation of Traversable and array operations

2015-07-15 Thread Benjamin Eberlei
On Wed, Jul 15, 2015 at 9:53 PM, Rowan Collins wrote: > On 15 July 2015 20:39:05 GMT+01:00, Levi Morrison wrote: > >Do note that the union types RFC would also alleviate some of this > >pain for user-land functions, since `array | Traversable` would cover > >the required access pattern. I think

Re: [PHP-DEV] Consolidation of Traversable and array operations

2015-07-16 Thread Rowan Collins
Benjamin Eberlei wrote on 15/07/2015 21:19: On Wed, Jul 15, 2015 at 9:53 PM, Rowan Collins mailto:rowan.coll...@gmail.com>> wrote: On 15 July 2015 20:39:05 GMT+01:00, Levi Morrison mailto:le...@php.net>> wrote: >Do note that the union types RFC would also alleviate some of this >

Re: [PHP-DEV] Consolidation of Traversable and array operations

2015-07-16 Thread Michael Wallner
On 16/07/15 11:26, Rowan Collins wrote: > Benjamin Eberlei wrote on 15/07/2015 21:19: >> >> But instanceof and anything related to Reflection or get_class or >> relevant code will fail on array. > > > Ah, yes, I hadn't thought of reflection type things. I don't think > instanceof would be a probl

Re: [PHP-DEV] Consolidation of Traversable and array operations

2015-07-16 Thread Tjerk Meesters
Hi! On Thu, Jul 16, 2015 at 6:39 PM Michael Wallner wrote: > On 16/07/15 11:26, Rowan Collins wrote: > > Benjamin Eberlei wrote on 15/07/2015 21:19: > >> > >> But instanceof and anything related to Reflection or get_class or > >> relevant code will fail on array. > > > > > > Ah, yes, I hadn't tho

Re: [PHP-DEV] Consolidation of Traversable and array operations

2015-07-16 Thread Levi Morrison
On Thu, Jul 16, 2015 at 4:38 AM, Michael Wallner wrote: > On 16/07/15 11:26, Rowan Collins wrote: >> Benjamin Eberlei wrote on 15/07/2015 21:19: >>> >>> But instanceof and anything related to Reflection or get_class or >>> relevant code will fail on array. >> >> >> Ah, yes, I hadn't thought of ref

Re: [PHP-DEV] Consolidation of Traversable and array operations

2015-07-16 Thread Rowan Collins
Levi Morrison wrote on 16/07/2015 16:23: People have talked about creating types like so: type Iterable = array | Traversable; which could then be used as normal: function foo(Iterable $f); I kind of like this idea. Why special case a pseudo-type if we can have a generic way of making the

Re: [PHP-DEV] Consolidation of Traversable and array operations

2015-07-16 Thread Levi Morrison
On Thu, Jul 16, 2015 at 9:42 AM, Rowan Collins wrote: > Levi Morrison wrote on 16/07/2015 16:23: > >> People have talked about creating types like so: >> >> type Iterable = array | Traversable; >> >> which could then be used as normal: >> >> function foo(Iterable $f); > > > I kind of like this ide