Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:11619 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 24334 invoked by uid 1010); 29 Jul 2004 15:36:44 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 24310 invoked from network); 29 Jul 2004 15:36:44 -0000 Received: from unknown (HELO blobule.suds) (66.11.170.154) by pb1.pair.com with SMTP; 29 Jul 2004 15:36:44 -0000 Received: by blobule.suds (Postfix, from userid 501) id 95A3B2F727; Thu, 29 Jul 2004 11:36:43 -0400 (EDT) To: Sara Golemon Cc: internals@lists.php.net In-Reply-To: <20040729150602.14998.qmail@pb1.pair.com> References: <20040729021337.73894.qmail@pb1.pair.com> <200407291117.09573.lpedretti@suserver.com> <1091112020.18112.15.camel@blobule.suds> <20040729150602.14998.qmail@pb1.pair.com> Content-Type: text/plain Content-Transfer-Encoding: 7bit X-Mailer: Ximian Evolution 1.0.8-3mdk Date: 29 Jul 2004 11:36:43 -0400 Message-ID: <1091115403.18102.18.camel@blobule.suds> Mime-Version: 1.0 Subject: Re: [PHP-DEV] GOTO operator From: robert@interjinn.com (Robert Cummings) On Thu, 2004-07-29 at 11:04, Sara Golemon wrote: > > Note > > ---- > > Goto jumping is O(1) if getting to the jump destination doesn't require > > a hash lookup due to "wuring" of the destination at compile time. If a > > hash lookup is required then it is probably something like O(lg n) which > > is still superior in efficiency to O(n). Additionally, while it is true > > that an O(lg n) lookup might be necessary at compile time to find the > > pointer to the labeled code block, this is a one time event and has > > little bearing on the efficiency overall when during runtime the goto > > might be hit thousands or millions of times. > > > *this* implementation of GOTO requires a hash lookup, however it could be > reworked to use the same backpatching as the ZEND_JMP ops used with > conditional statements. While doing that would speed execution time by > skipping the hash lookup, it'd slow compile time and remove the ability to > use complex expressions as goto targets (i.e. goto "foo$i"; ). I'm not sure whether this is feasible or not, but perhaps a mix of compile-time/runtime logic is possible. If the argument of the goto is a literal then a compile-time jump hook is created, otherwise the argument is evaluated at run-time. This would provide the best of both worlds, but as I said I have no idea as to its feasibility. Cheers, Rob. -- .------------------------------------------------------------. | InterJinn Application Framework - http://www.interjinn.com | :------------------------------------------------------------: | An application and templating framework for PHP. Boasting | | a powerful, scalable system for accessing system services | | such as forms, properties, sessions, and caches. InterJinn | | also provides an extremely flexible architecture for | | creating re-usable components quickly and easily. | `------------------------------------------------------------'