Murga-Projects Forums

Full Version: continue statement
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Lua has a break statement, but no continue like is commonly found in other languages. There are several references to this out there if you do a google search. One basically says it's not essential, which is true. On the other hand, it sure would be nice and it's not something that can be implemented by simply writing a lua function.

There's at least two places where the source code has already been done. I don't know if they actually work properly.

BLUA: bastardized lua
Lua Power Patches

I'm assuming this wouldn't add much to the size of the executable file.
OK, It's in ...

Hopefully a 0.6.X series build for this weekend with quite a lot of updates and fixes.

I am currently working on 0.7.X which does have some radical changes (under the hood, not affecting compatibility), and that's making things a little complicated ... 0.7.0 won't be out for a long time.

Cheers
JohnM
Thanks, John. murgaLua rocks!
Although I won't recommend using a statement that is not part of standard Lua (and will never be), I'm pleased to see murgaLua evolving.
In any case I'm looking forward to the next release, may it be this weekend or a subsequent one (just extrapolating experiences from prior announcements...Tongue)
Just curious....I don't understand what the benefit is. Not only does it seem nonessential, but it seems to serve no unique purpose at all. This is assuming continue merely jumps ahead to the next iteration, and doesn't have any other special use.

The Lua language already provides the same behavior, only in a passive way. Rather than specifically skipping the rest of a loop under a certain condition, you simply *don't* skip when that condition doesn't exist.

Or at least that's how I understand it =o)
Say you have a loop where you are reading through a database. Some records require extensive processing, some minimal processing, and some no processing at all. The conditions for checking which level of processing is required are complex. The continue statement allows you to do this in a gracious manner by avoiding hellacious nested if statements.
Either way ... It is a feature that I have missed myself (coming from other languages) ...

So I conclude that it allows you write code without having to re-think your logic with Lua in mind, so it's a good thing :-)

Cheers
JohnM
Reference URL's