[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Why is break not syntactically required to be the last statement in a block (anymore)?
- From: Lorenzo Donati <lorenzodonatibz@...>
- Date: Thu, 28 Jul 2022 17:44:34 +0200
On 28/07/2022 17:15, Egor Skriptunoff wrote:
On Thu, Jul 28, 2022 at 5:49 PM Lorenzo Donati wrote:
I would welcome a syntax like "break 4", to exit four loop levels.
Should the following statements also be valid?
break 3+1 -- arithmetic expression calculable at compile time
local level <const> = 3
break level+1 -- arithmetic expression with <constants> in it
That smells like computed goto, and don't see the need for that.
FWIW any syntax that allowed to specify a level would be good.
To avoid issues with what you mention, in order to just specify a
"static" level, also something like this:
or whatever other syntax that is easily parseable with no excessive
lookahead and no ambiguities or weird interaction with current language
Don't get me wrong, I love Lua has introduced "goto", but it is an
advanced features and using it excessively *do* lead to spaghetti code.
I don't like the fact that goto was meant to emulate features that in a
structured language should be reflected by (well established) control
structures (e.g. multilevel break/continue).