At 19:30 22/05/2010, Josh Davis wrote:
On 22 May 2010 17:04, Zeev Suraski <z...@zend.com> wrote:
> As one of the key people who designed PHP's type system I consider strict
> type checks completely alien to and counterintuitive in PHP and am therefore
> pushing to implement 'weak' typing instead, in a way that's consistent and
> familiar to users.

I would normally refrain from posting on the dev list but as a "user"
I feel the need to make sure that my position isn't misrepresented, so
here it is.

I think that users' opinion about language direction is very important, so thanks for writing.

As you wrote, you worked on PHP's _type system_ which is dynamic,
really cool, juggles strings with ints and what not. However, the
topic here is the _type hinting system_.

Well I actually wrote PHP's type hinting system too :) And it's no coincidence there are no type hints for scalars, and that stems directly from PHP's type system. As a part of introducing type hints to PHP back in 2003, there was a discussion about whether or not to add scalar type hints. Consensus was against it, and actually as a part of the agreement to add type hints to PHP - we agreed we'll 'never' introduce scalar type hints because of the baggage and inconsistency it comes with. Never is not a very long time when it comes to software though...

As far as I know, there's no
"weak" type hinting; if a method signature hints for an array and is
given an integer, it throws a catchable fatal error. Therefore, as a
user, what I am familiar to is a strict _type hinting system_.
Anything else would feel inconsistent to me.


That's true, but then, there's also no way to auto-convert class Foo to class Bar - while there is a way to auto-convert between scalar types in many (if not most) cases. Consider a simple example - class Child extends Parent {} strict type hinting is the equivalent of not allowing an object of class Child when a function expects an object of class Parent. Much like Child is_a Parent, "123" is_a int.

Zeev


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

Reply via email to