At 17:40 29.11.2002, Andi Gutmans wrote:
At 06:25 PM 11/28/2002 +0100, Marcus Börger wrote:
With current ZE2 it is possible to instanciate an abstract class. That is a class
that has at least one abstract method. When we add a flag field to class_entry
struct we can handle this. We simply need to set an abstract flag for the class
entry when any abstract method is added or inherited.

I updated the full patch to do it that way:
http://marcus-boerger.de/php/ext/ze2/ze2-f3p-21128.diff.txt
I thought about this but am not quite sure how I feel about this. I know that theoretically in C++ and Java you can't instantiate such classes but I'm not sure it'd be too bad in PHP.
If I were to implement this I'd probably use a counter to *remember* how many abstract methods a class has.

Andi
I would like a list of abstract methods in case the error is at hand more.
On the other side i do not know if the check is what we want. I mean it keeps you away
from using abstract classes what is a must in C++/Java. But for PHP this is only valid
as long as we do not:
a) allow to dynamically add new methods to instances/classes
(This would make some more thinks complicated but makes PHP more object oriented)
b) explicitly allow using abstract classes by decision here

Also the check has one negative aspect: it cost time (even thogh only a few small tests).

Your counter would be slower and could instead be simply computed when the error is
being generated. See pseudo code:
cnt = 0
foreach function in function_table
if function->common.fn_flags & FN_ABSTRACT
cnt++

Since there is until now no need to change the class_entry while inheriting a method we
can also show the class in which the method was introduced. Maybe like shown below:

class test {
abstract funcition a();
}
class fail extends test {
}

$t = new fail();
Fatal Error: You cannot instanciate abstract class fail (abstract methods: test::a)

marcus

p.s. I updated the complete patch: http://marcus-boerger.de/php/ext/ze2/ze2-f3p-21129.diff
after your commit.


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



Reply via email to