Re: [ZEND-ENGINE-CVS] cvs: ZendEngine2 / zend.h zend_API.c zend_API.h zend_compile.c zend_compile.h zend_execute.c

From: Date: Wed, 29 Oct 2003 10:25:07 +0000
Subject: Re: [ZEND-ENGINE-CVS] cvs: ZendEngine2 / zend.h zend_API.c zend_API.h zend_compile.c zend_compile.h zend_execute.c
References: 1 2  Groups: php.zend-engine.cvs 
Request: Send a blank email to php-zend-engine-cvs+get-1947@lists.php.net to get a copy of this message
Hello Andrei, Wednesday, October 29, 2003, 12:44:53 AM, you wrote: > On Wed, 22 Oct 2003, Marcus Boerger wrote: >> helly Wed Oct 22 15:59:58 2003 EDT >> >> Modified files: >> /ZendEngine2 >> zend.h zend_API.c zend_API.h zend_compile.c >> zend_compile.h zend_execute.c >> Log: >> Expand Interface C API. >> In short: zend_class_entry->interface_gets_implemented() allows to modify >> the class entry of a class when an interface gets implemented. > Can you explain this in a bit more detail? What is the purpose of this > handler? I had tons of discussions about the whole 'Iterator' stuff to which that handler is important, so i'll try to repeat the essence. The current iterator model consists of a single c-level class function: get_iterator(). And this does not involve any inheritance or userspace definition checks at all. Hence it would be nice to see if objects of a specific class can be iterated. That is what interface 'Traversable' does. On the other hand now we have the problem that somebody might declare a class that implements 'Traversable'. Now everybody thinks the objects have an iterator and therefore the code fails. To avoid this, interface 'Traversable' has an interface_gets_implemented handler that checks whether the implementing class has a c-level get_iterator function or will also implement the Interface 'Iterator' or 'IteratorAggregate'. Interfaces 'Iterator' and 'IteratorAggregate' now have a c-level funtion get_iterator which must be set in the implementing classes. Thus the interface needs to modify get_iterator of the implementing class. This they achieve in their interface_gets_implemented handler. Also this handler checks that the class isn't already traversable by having its own get_iterator function. However these checks allow a dual approach where an internal class has a c-level iterator but also implements the interface 'Iterator' or 'IteratorAggregate' and all the necessary methods to be used as a php level iterator. I hope this is explained good enough :-) -- Best regards, Marcus mailto:helly@php.net

« previous php.zend-engine.cvs (#1947) next »