Hello Cristiano,

Saturday, June 21, 2003, 2:07:09 AM, you wrote:

MB> Hello Cristiano,

MB> Friday, June 20, 2003, 9:03:33 PM, you wrote:

CD>> Ok, final methods and attributes are cool, but what about final classes ?
CD>> Is it hard to implement ? Or all classes must be able to be extended by
CD>> children ?

MB> It would be easy to implement and i made a running patch some time back. But
MB> we were uncertain about the result, whether or not it is really helpfull and
MB> needed in a loose typed language as PHP. But if you come up with a very good
MB> scenario were final classes are really needed chances are good they make it
MB> into PHP 5, if not chances are not so good.

Attached is a patch that allows final classes.

-- 
Best regards,
 Marcus                            mailto:[EMAIL PROTECTED]
? Zend/teststest.txt
Index: Zend/zend_compile.c
===================================================================
RCS file: /repository/ZendEngine2/zend_compile.c,v
retrieving revision 1.428
diff -u -p -r1.428 zend_compile.c
--- Zend/zend_compile.c 15 Jun 2003 13:58:50 -0000      1.428
+++ Zend/zend_compile.c 21 Jun 2003 19:02:17 -0000
@@ -1834,6 +1834,9 @@ void zend_do_inheritance(zend_class_entr
                && !(parent_ce->ce_flags & ZEND_ACC_INTERFACE)) {
                zend_error(E_ERROR, "Interface %s may not inherit from class (%s)", 
ce->name, parent_ce->name);
        }
+       if (parent_ce->ce_flags & ZEND_ACC_FINAL_CLASS) {
+               zend_error(E_ERROR, "Class %s may not inherit from final class (%s)", 
ce->name, parent_ce->name);
+       }
 
        ce->parent = parent_ce;
        /* Inherit interfaces */
Index: Zend/zend_compile.h
===================================================================
RCS file: /repository/ZendEngine2/zend_compile.h,v
retrieving revision 1.243
diff -u -p -r1.243 zend_compile.h
--- Zend/zend_compile.h 10 Jun 2003 20:03:24 -0000      1.243
+++ Zend/zend_compile.h 21 Jun 2003 19:02:17 -0000
@@ -99,6 +99,7 @@ typedef struct _zend_brk_cont_element {
 #define ZEND_ACC_FINAL                 0x04
 #define ZEND_ACC_INTERFACE             0x08
 #define ZEND_ACC_ABSTRACT_CLASS        0x10
+#define ZEND_ACC_FINAL_CLASS   0x20
 
 /* The order of those must be kept - public < protected < private */
 #define ZEND_ACC_PUBLIC                0x100
Index: Zend/zend_language_parser.y
===================================================================
RCS file: /repository/ZendEngine2/zend_language_parser.y,v
retrieving revision 1.119
diff -u -p -r1.119 zend_language_parser.y
--- Zend/zend_language_parser.y 15 Jun 2003 13:58:50 -0000      1.119
+++ Zend/zend_language_parser.y 21 Jun 2003 19:02:18 -0000
@@ -277,6 +277,7 @@ unticked_class_declaration_statement:
 class_entry_type:
                T_CLASS                 {  $$.u.constant.value.lval = 0; }
        |       T_ABSTRACT T_CLASS { $$.u.constant.value.lval = 
ZEND_ACC_ABSTRACT_CLASS; }
+       |       T_FINAL T_CLASS { $$.u.constant.value.lval = ZEND_ACC_FINAL_CLASS; }
        |       T_INTERFACE             { $$.u.constant.value.lval = 
ZEND_ACC_INTERFACE; }
 ;
 
-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to