On Thu, Apr 28, 2011 at 10:45:34AM -0700, Stas Malyshev wrote: > 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.
The Zend engine does function resolution at run time - others (eg HipHop) can afford to do it at compile time and so will know at compile time. I will accept that sometimes it must always be done run time, eg: $funcName($arg) but that still allows most calls at compile time. Anyway - the check for return type would be done in the called function, not the calling function. > >- 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. Which might be acceptable for some applications. For those where it is not then this feature may not be useful. This is an *optional* declaration, not mandatory - so if it does not suit your purpose -- don't use it. -- Alain Williams Linux/GNU Consultant - Mail systems, Web sites, Networking, Programmer, IT Lecturer. +44 (0) 787 668 0256 http://www.phcomp.co.uk/ Parliament Hill Computers Ltd. Registration Information: http://www.phcomp.co.uk/contact.php #include <std_disclaimer.h> -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php