Re: GOTO operator

From: Date: Tue, 03 Aug 2004 19:40:55 +0000
Subject: Re: GOTO operator
References: 1 2 3 4 5 6 7 8 9 10 11 12  Groups: php.internals 
Request: Send a blank email to internals+get-11883@lists.php.net to get a copy of this message
On Aug 3, 2004, at 3:09 PM, Derrell.Lipman@UnwiredUniverse.com wrote:
"Sara Golemon" <pollita@php.net> writes:
If you really, really, really wanted to do such a thing, you could still
do:
eval("goto foo$bar;"); to get the same effect, right?
Hmm, depends on how it's implemented. It will most likely not work I guess.
Nope... eval()'d code is in a separate op_array from the code it's eval()'d from. While it has the same variable scope it does not have the same label pool. Building in that kind of support is theoretically doable (and you'd get support for cross-file gotos in the process), but it complicates the execution flow somethin' fierce.
My contention was that eval() should work consistently. Andi indicated that there are other language features which would similarly not "work" when eval()'ed. If that's the case, then not having this work as well, is fine with me. (I voted -1 on variable labels even though I voted +1 on goto.) Out of curiosity, I wonder which other features would similarly not work when eval()'ed...???
break/continue don't work for the same reasons that goto shouldn't. George

« previous php.internals (#11883) next »