Re: Generics proposal
| From: | Lars Strojny | Date: | Tue, 06 Nov 2012 20:50:58 +0000 |
| Subject: | Re: Generics proposal | ||
| References: | 1 2 3 4 5 6 7 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-63767@lists.php.net to get a copy of this message | ||
Hey Sara,
can you already show us how your take on Generics would look like? Maybe this is a good moment for
HipHop and PHP to do something together.
Am 06.11.2012 um 04:14 schrieb Sara Golemon <pollita@php.net>:
> 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 <colder@php.net> wrote:
>> Hi,
>>
>> On Tue, Oct 23, 2012 at 4:17 AM, Levi Morrison <morrison.levi@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
>