Re: Re: [ZEND-ENGINE-CVS] cvs: ZendEngine2 / zend_default_classes.c zend_default_classes.h zend_execute.h zend_execute_API.c
| From: | Timm Friebe | Date: | Sun, 15 Feb 2004 18:26:51 +0000 |
| Subject: | Re: Re: [ZEND-ENGINE-CVS] cvs: ZendEngine2 / zend_default_classes.c zend_default_classes.h zend_execute.h zend_execute_API.c | ||
| References: | 1 2 3 4 5 6 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-7847@lists.php.net to get a copy of this message | ||
On Sun, 2004-02-15 at 16:09, Cristiano Duarte wrote:
> Hi Timm,
[...]
> IMHO, as you said, using an interface and letting the built-in class
> implement it is the best approach. But only instances of classes wich
> implement this interface should be throw or caught(language enforcement).
> With this enforcement, we can have a "catch all" for exceptions with
> less pain.
... and more flexibility for users like me who have their very own ideas
about a lot of thins:)
The following patch includes:
* An interface called "Throwable" which is implemented by the built-in
exception class. The interface is defined as following:
interface Throwable {
function getMessage();
function getFile();
function getLine();
}
* Checks on whether the exception thrown implements this interface
(rather than checking on subclasses of Exception), therefore
keeping the status quo of having a language enforcement on what
one can throw and "being clean" (which were the arguments for
this base class in the beginning, right?).
* The necessary changes to zend_catch_handler() which would only
check subclassing. Catch-all is implemented in the following way:
try {
// [...]
} catch (Throwable $e) {
print $e;
}
* A \n at the end of Exception::__toString() which does not require
one to write echo $e->__toString(), "\n" all the time.
Marcus, I do not think this adds any complexity. Especially not for the
user you are describing as "the average" and "wanting an easy exception
model" "the PHP way" "without any knowledge of interfaces":) For them,
this change is completely transparent (no changes need to be made).
In turn, it will make me and a couple of other people happy by leaving
us the freedom to decide whether we want (as Sterling put it)
all-your-base-our-belong-to-us-exceptions or design our own (and then
live with the fact that we can only accomplish 99% of the
built-in-exception's functionality).
- Timm
Attachment: [text/x-patch] zend_except.diff
Attachment: [text/x-patch] zend_except.diff