Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:7126 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 57443 invoked by uid 1010); 15 Jan 2004 16:16:01 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 57409 invoked from network); 15 Jan 2004 16:16:01 -0000 Received: from unknown (HELO phoebe.host4u.net) (209.150.128.26) by pb1.pair.com with SMTP; 15 Jan 2004 16:16:01 -0000 Received: from ctdprimary (dsta-aa203.pivot.net [66.186.171.203]) by phoebe.host4u.net (8.11.6/8.11.6) with SMTP id i0FGG0H17176; Thu, 15 Jan 2004 10:16:00 -0600 Message-ID: <026101c3db83$1e80c4a0$f7dea8c0@cyberware.local> To: "Marcus Boerger" Cc: References: <562031508046.20040114230741@marcus-boerger.de> <19800119111039.GC2178@bumblebury.com> <1572071705312.20040115101738@marcus-boerger.de> Date: Thu, 15 Jan 2004 11:17:48 -0500 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1158 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 Subject: Re: [PHP-DEV] SimpleXML: Moving Forward From: rrichards@ctindustries.net ("Rob Richards") > >> Thanks for moving backward. Since iterating is now worthless i am all for > >> removing it completley. I mean it isn't even in the spirit of the extension. > >> I will sleep over this tonight and probably remove the work of another full > >> week too. Just because it is too complex and doesn't fit in the current > >> scheme of SimpleXMl. Marcus, Ignore the user space issue for right now as I dont go into that at all. I dont see iterators as being worthless, however there is a behavior clash between the iterators and the arrays. When fetching properties returning arrays for multiple elements and returning a single sxe object for single elements (as the single sxe object will iterate the children of the returned object). A foreach will give different results depending upon which is returned. $a = $foo->a; foreach($a->b as $b) { ... } imo, the behavior should be the same regardless of what is returned. This pretty much means generalizing things to use either arrays or iterators. Disclaimer: Not advocating the following, just.may be a possible solution depending upon the ultimate scope of sxe. One nice thing is that if it were implemented as iterators, one could do: $b = $a->b; print $b; as $b should be the first returned sxe object, which would have the the iterator created (How to handle no elements would need to be determined - either NULL or an some tpye of empty sxe object). It could be thought of in terms of how the nodelist was implemented in dom, yet this is much scaled down and is implemented directly on the sxe object. This would also allow for other methods (such as children, attrbutes, count, etc.. if any are to be implemented), to be plugged right in, allowing for things like: $foo->b->count(), $foo->a->children()->count(), $foo->a->attributes(), etc... However to implement something like above as well as to implement iterators in sxe at all, they are going to need to point to the node proxies rather than to the libxml nodes themselves otherwise it can be made to segfault (as is the case today): $foo = simplexml_load_string('b1valb2val '); $a = $foo->a; foreach($a as $b) { foreach($b as $subb) { print $subb."\n"; unset($foo->a); } } Implementing these iterators wouldnt be as simple as they previously were, but would offer a lot more functionality and flexibilty (interally wise) Rob