Re: GOTO operator
| From: | Andi Gutmans | Date: | Fri, 30 Jul 2004 19:13:04 +0000 |
| Subject: | Re: GOTO operator | ||
| References: | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-11715@lists.php.net to get a copy of this message | ||
At 03:11 PM 7/30/2004 -0400, Robert Cummings wrote:
On Fri, 2004-07-30 at 13:11, Andi Gutmans wrote: Rob, First of all I don't know where you are getting O(n) from because the operation is O(1). Secondly, I just don't understand what the sudden necessity for the goto construct is when over the years we have barely ever had a PHP developer asking for it. And please guys, don't use C optimization comparisons as an example. This doesn't apply to PHP... Goto is O(1) -- cascading through switch cases till you hit the right one is O(n) where there are n possible cases. Now if I have to run through that damn switch time m times, then my runtime is O(mn) whereas with goto it's O(m). This isn't a C optimization, this is just the best way to do it sometimes. Even if goto was a runtime lookup I'm still better off with O(m lg n).But you have break n in PHP. I guess we are talking about different things. Can you show me an example of when it'd be O(n)?