[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Feature request: enhanced break
- From: Patrick Donnelly <batrick@...>
- Date: Tue, 25 Nov 2014 12:40:54 -0500
On Mon, Nov 24, 2014 at 2:26 AM, Dirk Laurie <dirk.laurie@gmail.com> wrote:
> 2014-11-24 8:54 GMT+02:00 Oliver Kroth <oliver.kroth@nec-i.de>:
>
>> how do you want to pick up the value break provided?
>
> That would be hard if an expression is allowed, which is why I am
> asking for a numeric constant. At present, the compiler generates
> an invisible label "break" and actually does `goto break`. For the
> extension, it would generate an invisible label that cannot be a
> Name, e.g. `break.2`.
This got me thinking about what if the compiler made implicit labels,
e.g. "__break2". I've created an example below with them explicitly
marked:
do
-- loop 1
for ... do
if ... then
do
-- loop 2
for ... do
if ... then
goto __break2
end
do
-- loop 3
for ... do
::__continue1:: -- loop 3 continues loop 3
end
::__break1:: -- loop 3 breaks out of loop 3
end
end
if ... then
goto __break2 -- **** Doesn't work! ****
end
::__break1:: -- loop 2 breaks out of loop 2
::__break2:: -- loop 3 breaks out of loop 2 and 3
end
end
::__continue1:: -- loop 1 continues loop 1
::__continue2:: -- loop 2 continues loop 1
::__continue3:: -- loop 3 continues loop 1
end
::__break1:: -- loop 1 breaks out of loop 1
::__break2:: -- loop 2 breaks out of loop 1 and 2
::__break3:: -- loop 3 breaks out of loop 1, 2, and 3
end
Alas, this does not work (at least, not without extra effort on the
compiler). I've marked above where it fails.
--
Patrick Donnelly