Hey,

Marcus didn't mean it adds complexity to the code but to PHP. It's obviously quite easy to implement this interface; implementation was never a problem.
I don't really care too much if we have such an interface or not, although I do think that it just makes things complex and I doubt almost anyone will have a need for it.
I think the arguments given on this list for why we need this interface were mainly academic and an attempt of people familiar with Java to copy the hierarchy. The actual times you will need such an interface is quite rare and I don't think it's worth the complexity for the one in a million purist guy (i.e. people who want all their classes to inherit from a CObject including exceptions).


Andi

P.S. - BTW, why not call it IException (or ExceptionInterface) instead of Throwable? I think for people who don't know Java, it makes more sense.


At 07:26 PM 2/15/2004 +0100, Timm Friebe wrote:
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

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

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



Reply via email to