At 10:04 AM 3/28/2003 +0000, Wez Furlong wrote:
The point is that we don't raise an E_ERROR when you pass the wrong type
of parameter to any of the other PHP functions.

Really? I think that some functions which use resources do error out if you pass a wrong type (although I'm not quite sure), but there's no reason it shouldn't.



A "real" programmer is not a Java (*spit!*) programmer; it is someone
that wants to make their code as robust as possible.

Again, I will use the idea of a SOAP server implementation (or any RPC
server); in order to send the correct response to the client, it needs
to be able to catch any runtime error and act appropriately.  Why is
this an issue?  Why doesn't the programmer write code that doesn't use
type-hints?  Well, maybe they won't, but some other person using the
library might, and then they will wonder a). Why it doesn't work?  b).
What is the point of having a type hint anyway?

The point of type-hints is to be able to catch errors in your code quickly and not having to write checks, the point isn't to catch problems in your code at run-time. And as I said before, if it doesn't suite you then don't use type-hints and use instanceof like you would have done 2 weeks ago. It's not a disaster so don't make it sound like one. So much has changed in the past two weeks? If you need to catch errors because you are writing something generic such as SOAP (which most of the PHP community doesn't do) then go ahead and do the instanceof's you need to do.



Using E_ERROR also prohibits using CLI or embedded PHP in a long-lived
application.  I know that PHP is designed primarily for use in a web
server, but it seems incredibly short sighted to design new features
that make using CLI or embed impossible.

Exceptions have a potential of leaking memory. I have mentioned in the past that I wouldn't base my applications logic on exceptions but only use it in error conditions to clean-up and/or give a nice message. You are talking about using it as part of your application logic.
You are convincing me more and more not to throw an exception with type hints.


Andi


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



Reply via email to