lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

On Wed, Feb 23, 2011 at 3:23 AM, HyperHacker <> wrote:
> On Tue, Feb 22, 2011 at 11:52, Steve Litt <> wrote:
>> On Tuesday 22 February 2011 13:17:00 Pierre-Yves Gérardy wrote:
>>> > roberto> It always strike me why gotos are considered evil and ugly,
>>> > roberto> but continuations, which are a completely unrestricted form
>>> > roberto> of computed/assigned gotos, are considered beautiful. Maybe
>>> > roberto> the problem with gotos is that they are too restrictive?
>>> I think that the problem is social, not technical.
>>> Continuations are conceptually more complex, and as such are less
>>> likely to be abused by clueless people.

---- >8

> I think the biggest issue people have is that goto can easily be
> abused to create unreadable spaghetti code, whereas continue is a bit
> harder to misuse. Of course both can be used well and both can be used
> poorly, but goto makes it much easier to construct big tangled messes
> that become difficult to follow or debug.
> Goto also has some negative stigma attached to it, and so I fear
> people would look down on any language that encourages its use, even
> if it's used well.
> I also wonder, if Lua had goto, what syntax would define a label?
> "foo:" and ":foo" would both be ambiguous, and I'm having trouble
> thinking of anything else that wouldn't be ugly. Then as well there
> needs to be a mechanism for keeping track of those labels.
> In all my years of coding I've never found a need or desire to use
> goto, whereas continue is something I often find myself wishing when I
> have to write a loop like:
> while something() do
>        local x = foo()
>        if x then
>                --...many lines here...
>        end
> end
> as opposed to:
> while something() do
>        local x = foo()
>        if not x then continue end
>        --...many lines here...
> end

continue? continuations? you lost me at 'while'.