Hi,

On Mon, Oct 22, 2012 at 9:44 PM, Anthony Ferrara <ircmax...@gmail.com> wrote:
> Stas,
>
> On Sun, Oct 21, 2012 at 12:51 PM, Stas Malyshev <smalys...@sugarcrm.com>wrote:
>
>> Hi!
>>
>> > Hello, list. I want to propose generics.
>>
>> Please no. If you need Java, you know where to find it. Java has a set
>> of great tools, great books, great community. And it's completely free.
>> Anybody who needs Java can just do it. I see no need to turn PHP into Java
>>
>
> This is not about turning PHP into Java. Can we get over that old rhetoric
> already? Instead of bashing proposals like this, can we discuss them,
> instead of this hatred for all things strict?
>
> With that aside, I have mixed feelings on this.
>
> On the one hand, I love the functionality. The ability to have
> meta-type-safety without having to pollute the environment with tons of
> empty classes with nothing more than a type hint (for all collection types)
> is huge.

Let's not talk about type safety, there is nothing that is type-safe here.
What this proposal is describing is syntactic sugar for runtime type
checks (which is exactly what type hints are anyway).

The arguments for and against runtime type checks are the same that
they were 5 years ago: unlike other languages that support generics:
PHP will have: no compiler support => no static guarantees => runtime,
unnexpected errors.

The argument should really be whether the cost of having that syntax
in the language is less than the benefits of catching such errors
"early" (early being usually one stack frame earlier, but I have no
definite stats on that).

> It would definitely make defensive programming much easier.
> 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.

>
> On the other hand, the syntax leaves a lot to be desired. It's quite
> confusing and really is ugly. As far as how to fix the syntax, I'm not sure.
>
> But I would like to voice my support for the concept...



-- 
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