Sorry to be late to the conversation, but fwiw, HipHop is adding
Generics (and some other cool things) to our PHP implementation.  We
plan to provide a PHP equivalent implementation in the form of a
pre-processor extension which can live in PECL.  The implementation
would of course be cleaner if done directly in the engine, but with
APC the performance hit of doing an extra transformation pass should
disappear. Hopefully this satisfies both the want for Java/C++-like
syntax without "polluting" the language.

-Sara

On Tue, Oct 23, 2012 at 4:21 AM, Etienne Kneuss <col...@php.net> wrote:
> 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
>

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

Reply via email to