Hi,

On Tue, Oct 23, 2012 at 4:17 AM, Levi Morrison <morrison.l...@gmail.com> wrote:
>>> 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.

If you test every time you add one element, that's still O(n) tests
where n is the size of the array, the only benefit is that it is not
checked for each calls to a function. But now we are talking about
attaching non-trivial types to variables, and non-trivial checks in a
lot of places (think references etc..), let's not go there...

>
> I am also supportive of the idea of having generics, but I am not sure
> that the work it would take is worth it.



-- 
Etienne Kneuss
http://www.colder.ch

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to