|
Hi On Tue, 14 Jun 2011, Roberto Ierusalimschy wrote:
On Tue, Jun 14, 2011 at 12:35 PM, David Given <dg@cowlark.com> wrote:@label: -- 0 do goto label do @label: -- 1 end @label: -- 2 end Does the goto jump to 0, 1, 2, or is this a compilation error?Using the experimental method, it goes to the first label. In fact, putting a 'goto label' in block 1 still goes to 0, which is a wee bit surprising.It goes to label 2, does it not? Label 1 is not visible (inside a block). Label 0 is shadowed by label 2, which is in the same block as the goto.
For me, this is a sign of future confusion :-(
Maybe it would be safer to be a compilation error, but this is tricky. Consider the next, similar code: do goto label do @label: -- 1 end @label: -- 2 end @label: -- 0 Now, when the compiler sees label 0, label 2 and label 1 are out of scope, so it makes no sense to raise an error.
It would hurt the compiler to stop on label 2 (raising an error) to avoid confusion? Regards, Tomás