[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: proposal: state machine syntax also usable for continue / nested break
- From: Axel Kittenberger <axkibe@...>
- Date: Fri, 28 Jan 2011 14:19:30 +0100
There is nothing wrong with labeled loops and breaks, its not so an
uncommon feature in languages, and useful in some cases, altough in
practice not something you encounter everyday, and only makes life
easier now and then. What I doubt is labeled breaks just as reason to
circumvent the need for continued loops, At least the coding examples
I've seen so far make things just look more confusing freightining
instead of gaining clarity, another do end block for every loop that
wants a continue? isn't that all just overkill? What about the "redo"
option that was used argument? Is that covered?
Gotos are not "perfect" in any way, not only scope, gotos are evil as
any overuse they create terrible hard to maintain code, and its easy
to do bugs, hangs etc. At least my idea about scripted languages was
all about making code easy and maintainable.One of the few exception
that make C's goto worth to be used is common error handling for a
function, but thats covered with error() anyway.
On Fri, Jan 28, 2011 at 2:07 PM, Roberto Ierusalimschy
>> This is all so kinf of wierd just to circumvent continue? Whats so bad
>> a plain continue? Or is just a arbitrary grown history of refusal
>> without a r real deep reason?
> We already explained our reasons. And labeled breaks is nothing
> wierd. It is an old and well-understood control structure.
>> Personally I'm coding for 20 years now, for several years I learned with
>> this kind of toy-problems, mini projects,etc. I never used continue,
>> didn't even know it existed. Then at some point (also with the dawn
>> of the internet in large scale) I started to analyze code of others,
>> and have seen how they use 'continue' to make code thats better than I
>> used to, less intendation blocks, less temporary variables, more easy to
>> maintain. Since then I'm used to use it, and still find it akward Lua
>> forces me not to.
> This explains a lot. As you, most people ask for 'continue' because
> they learned to use it from other languages. People do not ask for
> labeled breaks because few languages offer it, and so many people have
> not yet learned to use it.
> In Lua, we favor generic and powerful constructs. Actually, a 'goto'
> would be almost perfect. But its interaction with variable scoping
> is quite confusing in a language with first-class functions like Lua.
> Labeled breaks seem the next best thing, as it allows any forward goto
> that does not enter a variable scope.
> The current source for 5.2 uses 2 continues plus 16 gotos. All of them
> could be replaced by labeled breaks, except one that is used inside a
> switch to jump to the default case. (Several gotos in the source would
> be unnecessary in Lua, as they are used to emulate tail recursion; but
> anyway they could be replaced by labeled breaks plus an infinite while.)
> -- Roberto