Re: Re: Type hints revisited [IllegalArgumentException instead of E_ERROR]
| From: | (Marcus Börger) | Date: | Mon, 31 Mar 2003 18:32:57 +0000 |
| Subject: | Re: Re: Type hints revisited [IllegalArgumentException instead of E_ERROR] | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-547@lists.php.net to get a copy of this message | ||
At 14:03 31.03.2003, Stanislav Malyshev wrote:
WF>> Type hinting, if it causes a bail-out, renders the scripts WF>> non-portable to (the growing number of) applications that intend to WF>> stick around for longer than a short web-request. Well, I do not completely understand how it is "non-portable". If the script calls "hinted" function with wrong parameters, it is a fatal error - I see no sane (meaning, safe not for your particular application, but for all of them) way to continue from here except for saying the user "Well, doh!" and exiting. That's like calling function with wrong name - how can you continue from there and expect it works?Exceptions are exceptions (try to think about the meaning of the spoken word). And the sense of exception handlers is to take care of such exceptions. Now calling a non existing function or calling it with the wrong parameters is an exception. The first is the exception that the necessary function is not present and the second is the exception that an illegal parameter was passed. The first typically happens when some dynamic loading failed. As someone writing safe and robust code you should take care of this. And in some cases you might be able to do a fallback rather then the only current possibility to pull out a nice error message. The second typically happens in when in a portable application something went wrong. In those cases there is only some little part not working and often this can be more or less ignored if taken care of in an exception handler. Having exceptions *only* to throw user defined exceptions stands in total contrast to what they are about. If so the less expirienced programmer is lead to use his own exceptions. And as someone already said (was it Zeev) typically exceptions are to expensive. regards marcus