[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: [ANN] Lua 5.2.0 (beta-rc1) now available
- From: Mike Pall <mikelu-1106@...>
- Date: Tue, 14 Jun 2011 16:23:04 +0200
Roberto Ierusalimschy wrote:
> > >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?
>
> I am talking about the conflict between label 2 and label 0; assume
> label 1 is not present. How the compiler can stop on label 2?
It doesn't need to. But it ought to error out when seeing label 0.
Scoped labels do not correlate well with the mental model that
most people have for goto. Nor is that a particularly useful
feature. Labels should be unique per function.
Implementation-wise you just keep all labels, but mark them as
dead when the scope ends. You get better error messages, too.
--Mike