Re: [PHP-DEV] ZE2 + public/protected/private/final

2002-11-29 Thread Marcus Börger
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 
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] ZE2 + public/protected/private/final

2002-11-29 Thread Andi Gutmans
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


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



Re: [PHP-DEV] ZE2 + public/protected/private/final

2002-11-28 Thread Marcus Börger
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

marcus

At 18:10 25.11.2002, Marcus Börger wrote:
After Andi had commited some cleanups my version from PPP is a bit smaller.

My version is of cause only my private idea of implementing PPP. The 
solution i went
on has some advantages and disadvantages. One of the disadvantage is that 
i do not
allow redeclaring of private member functions. On the other hand and from 
my current
perspective this should allow a faster implementation. But especially here 
i would
appreciate every hint for alternatives.

Besides public/protected/private i introduced final which is available as 
a smaller patch
without public/protected/private stuff. Final can be used if you do not 
want anybody to
modify (overload) one of your methods.  The implementation is very simple 
since only
one new keyword "final" is used which can be stored in fn_flags of 
methods. While
inheriting there needs to be one additional check: A final function cannot 
be redeclared.
And i added two compiler errors in the language parser to have better 
messages when
someone tries to declare a method final and abstract. The main 
disadvantage here is
that final needs the a keyword.

You can download updated patches and test files here:
http://marcus-boerger.de/php/ext/ze2

Comments welcome !!!


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


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




[PHP-DEV] ZE2 + public/protected/private/final

2002-11-25 Thread Marcus Börger
After Andi had commited some cleanups my version from PPP is a bit smaller.

My version is of cause only my private idea of implementing PPP. The 
solution i went
on has some advantages and disadvantages. One of the disadvantage is that i 
do not
allow redeclaring of private member functions. On the other hand and from 
my current
perspective this should allow a faster implementation. But especially here 
i would
appreciate every hint for alternatives.

Besides public/protected/private i introduced final which is available as a 
smaller patch
without public/protected/private stuff. Final can be used if you do not 
want anybody to
modify (overload) one of your methods.  The implementation is very simple 
since only
one new keyword "final" is used which can be stored in fn_flags of methods. 
While
inheriting there needs to be one additional check: A final function cannot 
be redeclared.
And i added two compiler errors in the language parser to have better 
messages when
someone tries to declare a method final and abstract. The main disadvantage 
here is
that final needs the a keyword.

You can download updated patches and test files here:
http://marcus-boerger.de/php/ext/ze2

Comments welcome !!!


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