Re: Consolidation of Traversable and array operations

From: Date: Thu, 16 Jul 2015 16:01:37 +0000
Subject: Re: Consolidation of Traversable and array operations
References: 1 2 3 4 5 6 7 8 9 10  Groups: php.internals 
Request: Send a blank email to internals+get-87202@lists.php.net to get a copy of this message
On Thu, Jul 16, 2015 at 9:42 AM, Rowan Collins <rowan.collins@gmail.com> 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 idea. > >> Why special case a pseudo-type if we can have a generic >> way of making them in user-land? > > > Well, for the same reason as large amounts of the core library exist (and > PHP's is small compared to some): standardisation and ease of use. I think > "array | Traversable" is a common enough use-case that it deserves a > built-in name, even if a userland naming system is available. I assume if type Iterable = array | Traversable can be built in user-land then it will be done using the same mechanisms in core (meaning it wouldn't be a special case or one-off type).

« previous php.internals (#87202) next »