On Sun, 2004-02-15 at 12:08, Zeev Suraski wrote:
> At 12:04 15/02/2004, Timm Friebe wrote:
> >I agree with Sterling. What if I have some really methods in my base
> >class that I rely on being existant in each and every subclass of it,
> >including Exception (or any other name I thought of to work around
> >"Exception" being built-in)?
>
> Couldn't quite understand that. Can you elaborate on what you mean exactly?
Sure:
Assume, in my current setup, I have my own exception class, which
extends my own base class, called Object. The class Object has a
method getClass() which returns the Reflection_Class for $this (
there are actually some more methods in it that are available to
all extending classes).
Example, shortened for brevity:
<?php
class Object {
public function getClass() {
return new Reflection_Class($this);
}
}
class _Exception extends Object {
}
$e= new _Exception();
var_dump($e->getClass()->getName());
?>
In all of my code, I rely on each and every object having this
method, which of course will be broken for any exception I will
now need to extend from the built-in exception class (that does
not have this method).
Of course, I could always extend the built-in exception and add
the base class' methods to it, too, resulting in duplicate
code and not solving the problem for Exception itself.
Without the requirement to extend the built-in exception class,
I could get around this by simply not using it and for those
cases where it might occur, catching it and rethrowing my own
exception.
As of B4, this is no longer possible. That's why i was agreeing
to Sterling in saying it should be optional to use the built-in
exception class. If there was a requirement to implement an
interface (call it Throwable, for instance), simply let the
built-in class implement it. People wouldn't have to get into
interfaces when using (and/or subclassing) it but *only* for the
case when they want something similar to what I described above.
People wanting this will tend to be the kind of people that know
about interfaces, anyway:)
- Timm
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php