> 
> > As for my own example, many state machines make extensive 
> use of goto 
> > to avoid recursive calls.
> 
>      Goto is not required for that.  State machines such as the
>      following
> 
>          state1:
>              ...
> 
>              goto state99;
> 
>          state99:
>              ...
> 
>              goto state2;
> 
>          done:
> 
>      can easily be rewritten as
> 
>          while (!end_condition) {
>              switch (state) {
>              case 1:
> 
>                  state = 99;
>                  break;
> 
>              case 99:
> 
>                  state = 2;
>                  break;
>              }
>          }
> 
>      - Sascha


Last time I looked (which was a while ago so may have been since improved) PHP 
performed a linear search of case values, so took n/2
comparisons (where n is number of cases) on average to find the correct block 
to execute in a switch statement, wheras using goto
doesn't have to perform any.

Jared

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

Reply via email to