Re: base class
| From: | Christian Schneider | Date: | Thu, 22 Jan 2004 22:36:46 +0000 |
| Subject: | Re: base class | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-7284@lists.php.net to get a copy of this message | ||
Marcus Boerger wrote:
Well you design a class tree/framework and should know what you have done. If not use reflection.So to be able to later add a constructor to a base class one would be stuck with one of two options: 1) have __construct() in all classes from the start, even if it's empty. Ugly and stupid. Not even Java forces one to do that :-) 2) Use reflection in all extending classes to check if a constructor exists. Inacceptable, a joke at best.
A change is a change.OO is about extending classes without having to touch users of the class if the interface remains the same. Arguing that adding a constructor changes the interface is silly, especially if it is a parameterless one.
That would slow down execution ***very*** much and makes absolutely no sense at all. If you want a base class for your classes do it. Fell free.I don't buy that: The place where zend_error(E_ERROR, "Can not call constructor"); is done could easily just ignore the call. Maybe it could be turned into E_NOTICE or E_STRICT for people who want to be notified about such calls. I'll post a patch on the WE if noone else is doing it. - Chris