lua-users home
lua-l archive

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


[I searched for prior thread, which I remember existing, but I could
not find it.]

When I'm in a loop that uses continue, there is often a simple
condition that I'm checking for, which will determine if I should skip
or not.

Here is a fake example:
```
--if x is nil use y. If x os false or y is false-y, continue
x = x == nil and y
    or not x and  goto continue
    or x
```

I imagine that this does not work for good reason. However, I've had
multiple occasions where I would have preferred this style over:

```
local x = x == nil and y or x

if not x then
    goto continue
end
```

Even to me, the second style is a bit clearer, but a comment can make
the first one clear and it has the benefit of dealing with this
initialization in one go.

While I would prefer that goto could be used in expressions, history
has taught me that I'm about to have my mind changed. If someone could
do me the favor of providing me with that narrative, I'd be most
appreciative. :)

-Andrew