Hi!

I see many advantages of the introduction of return type hinting.
- you can guarantee that your methods returns only what is explicitly
stated (or else it blows up, the same as for arguments)

You can't, because function resolution happens in runtime, so the only point you know what the function called "foo" returns is the moment where you're already calling it, not a moment before.

- it can save you from having to define the return type in phpdoc, your
code can define it's behavior

Why I need being "saved" from documenting my code properly? Anyway, the function code defines the behavior, declaration of return type just ensures function would fail in runtime if your code tries to return unexpected data - but how is it helpful? The client of this function doesn't even know that before actually calling it!

- I think maybe the language itself could use that information, for
performance, etc. improvements (we know that the return value will be

That would need static compile-time binding of functions, which implies static binding of includes, etc. - basically, compiling PHP code as a whole in one monolitic application.

created runtime, but we can throw it away if it doesn't match the return
type or something), maybe we can use that information to throw errors on
compile time if we find a non runtime decided return value which doesn't
match with the return type.

Sorry, what is "non runtime decided return value"? And how is "compile time" different from "runtime" in your opinion - when exactly that "compile time" happens?
--
Stanislav Malyshev, Software Architect
SugarCRM: http://www.sugarcrm.com/
(408)454-6900 ext. 227

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

Reply via email to