Hello everyone,

I'm emailing to this list to suggest that "support for type-hinted return values"[1] be in added in PHP 5.y.x instead of PHP 6. Conceptually, this is the second half of "type-hints" already introduced in PHP 5.

This is why: When a programmer is designing an interface (the language construct), only what is accepted by the interface can be defined. Calling code is left with no idea of what the return type is going to be.

Even with great documentation, when designing an interface, it would be great to be able to take the responsibility of type checking return values from calling code onto the interface. To design a full interface, the interface designer should be able to say that a caller can call method X with input types Y and Z, then expect an object that implements interface Z to be returned. The caller should not have the responsibility of handling any other return types.

I'm looking forward to many of the upcoming features of PHP6, but PHP 6 is far from being stable (?). This is a change will break any existing code and is not a big extension on how PHP, a weakly typed language (not necessarily a bad thing), handles types.

[1] http://oss.backendmedia.com/PhP60

ps - please let me know if posts like these should be posted elsewhere

Thanks,

David N. Q. Duong

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

Reply via email to