tags:

views:

138

answers:

2

I love Lua, using it for more and more projects as the primary (not embedded) language. My current project is approaching 10,000 lines and will probably end at about 15,000 lines. What have you found useful when developing in Lua at that scale? What have you bumped your head against, and what solutions have you found? I'm thinking about development tools, language features & techniques, third-party modules?

My top 3:

  1. strict.lua - I use a modified version of this. Without being alerted to accesses of unused/unintended variables I'd go crazy.

  2. coroutines - not for their multithreading capability, but for their continuability. Very useful for simplifying the implementation of state machines.

  3. serialization function - indispensable for dumping table contents, and for persisting tables to disk (I use this many times when otherwise I'd probably have reached for a database).

My Wishlist:

  1. Visual debugger for OS X. I'm using print()s now, but a debugger that would let me single-step through source files would be great.

  2. A continue statement. Using the repeat...until true workaround is ugly, and too many nested ifs becomes complex and ugly.

  3. A metamethod that's invoked when an existing table member is modified.

Any other tips for larger-scale Lua development?

+4  A: 

A continue statement. Using the repeat...until true workaround is ugly, and too many nested ifs becomes complex and ugly.

Have your loop body be a function call; then return becomes continue.

A metamethod that's invoked when an existing table member is modified.

You can implement this yourself by using a proxy table B that stores all of the actual data for table A - the newindex/index metamethods on A intercept writes/reads and modify/lookup from table B instead. Since A never gets anything written to it, all writes hit newindex.

Amber
+1  A: 

Possible debugging options for OS X:

Judge Maygarden