Cameron Laird's personal notes on Lua

I'm not much of a Lua programmer myself (yet). My involvement has been to co-author columns on it in 1998, 2002, and 2004 (biggest regret from this column: failing to mention SciTE's new Lua scriptability), and to deliver a paper Roberto Ierusalemchy wrote on it for a conference session I chaired.

Here's some of what I know about Lua: it's light-weight, easy to learn, and easy to extend and embed (something like Tcl, especially early Tcl). Even Roberto sometimes refers to it as Yet Another Scripting Language. It doesn't pretend to have a particularly rich run-time library. Like Pliant and some Forth, LISP, and Tcl work, Lua emphasizes meta-programming for large projects, rather than "features". TkLua is available. An executable shell is available. Extensions to CORBA, SNMP, ODBC, ... are available. Release 3.1 in summer 1998 gave anonymous functions, closures, and multiple interpreters; 3.2 brings conditonal expressions; and ... well, see Lua's home for more details about on features.

Lua's tables are not bound to a variable name; "they are dynamically created. . . . The advantage is that tables can freely refer to other tables, and therefore have expressive power to model recursive data types, and to create generic graph structures, possibly with cycles."

[Comparisons with other languages--coming May 2004.]

Roberto's papers [give references] are good to read.

A couple of Roberto's examples give a good feel for Lua's regular expression capabilities (which include application of functions after pattern-matching), and their applicability to Web programming:

        function cgilua_unescape (str)
	  str = gsub(str, "+", " ")
	  return gsub(str, "%%([0-9A-F][0-9A-F])",
		  function(x) return strchar(tonumber(x, 16)) end)
	end
and
        function cgilua.pair (key, value)
	  key = cgilua.unescape(key)
	  value = cgilua.unescape(value)
	  cgi[key] = value
	end

	function cgilua.decode (string)
	  gsub(string, "&?([^&=]*)=([^&=]*)&?", cgilua.pair)
	end
[Find original for these.]

Several of us keep notes at this Wiki page focused on Lua.

Key official resources:

Not official, but quite exciting, is Jean-Claude Wippler's Wiki for Lua.
Cameron Laird's personal notes on Lua/claird@phaseit.net