Re: Consolidation of Traversable and array operations
| From: | Rowan Collins | Date: | Thu, 16 Jul 2015 15:42:20 +0000 |
| Subject: | Re: Consolidation of Traversable and array operations | ||
| References: | 1 2 3 4 5 6 7 8 9 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-87201@lists.php.net to get a copy of this message | ||
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. Regards, -- Rowan Collins [IMSoP]