if you have a look at a parser generated for PHP (eg. this - quite large file)
http://cvs.php.net/co.php/pear/HTML_Template_Flexy/Flexy/Tokenizer.php?r=1.51



The original Java/C# stuff does switch/case, In PHP due to the fact you have to evaluate each switch, it used to be quite slow,
I ended up replacing it with variable function calls, which even with PHP's penalty on calling functions was faster.


I suspect variable goto's would have made this code increadibly fast, in comparison.

You can do parsers using switch/case or $function, but unfortunatly they are slow..

Regards
Alan


David Chen wrote:
"Michael Walter" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]

Another possibility, possibly more concise, would be to introduce a
"scoped" keyword (or similar) in the spirit of "global":

  scoped $foo;

might make $foo's destructor be called at the end of the current scope
(whether left by a return statement or by an exception).

Note that this only solves one part of the problem which could be
summarized as "resource management". I'm not sure about generated code -
did someone already post an example where goto might be useful in that
case or did I miss that one?


Considering that some don't accept exceptions to be a valid alternative to
gotos, I don't think they'll accept a clearly OOP solution. And yes, I'm
also still waiting for a code-generation example, but I guess we'll just
assume that gotos are useful there (I use JavaCC, a Java-based top-down
generator, so yes there's a lot of recursion but it looks pretty clean to
me).


David Chen



--
Can you help out?
Need Consulting Services or Know of a Job?
http://www.akbkhome.com

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



Reply via email to