Re: Generics proposal
| From: | Levi Morrison | Date: | Tue, 23 Oct 2012 02:17:03 +0000 |
| Subject: | Re: Generics proposal | ||
| References: | 1 2 3 4 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-63606@lists.php.net to get a copy of this message | ||
>> Especially if the ability was afforded to arrays as well (function
>> foo(array<Bar> $array){})...
>
> This would require O(n) runtime tests, I would definitely not go there.
Actually, it does not require O(n) runtime tests. The solution is
simple: store the type when it is created. Whenever an element is
added, make sure it matches the correct type. All this does is add
some flat overhead.
I am also supportive of the idea of having generics, but I am not sure
that the work it would take is worth it.