Welcome to the Dictionary of Programming Languages, a compendium
of computer coding methods assembled to provide information and
aid your appreciation for computer science history.
Browse the dictionary by clicking on a section:
Get a full dump of the dictionary:
List of Names
- Language type:
Lua is an interpreted structured
language designed for embedding into other
applications. It is intended for use as
an extension and scripting language,
especially for applications with
requirements for structured data storage.
Because it is intended for use as an
application extension language, Lua does
not have the notion of a 'main' program
or initial entry point; instead, all code
is assumed to be invoked from the host
The syntax of Lua is somewhat similar to
that of Pascal, but the data type system is
quite different. Like many scripting
languages, Lua is loosely typed: variables
need not be declared, and may hold any kind
of value. Data types supported by Lua
include real numbers, strings, functions,
and tables (associative arrays). Lua
also has a distinguished 'nil' value type,
and an extension data type called
'userdata' that can store C pointers
for use by the host application.
Lua associative arrays subsume other data
types like arrays and tuples, just as they
Control structures supported by Lua include
various conditional and looping constructs.
The language has
no error handling constructs, instead
errors are usually
routed to pre-defined handler functions.
Like Perl, Lua support multiple return values
from functions and variable numbers of arguments
Scope is very simple in Lua: all variables
are either global, or local to a particular
block. The default is global, local
variables must be explicitly declared so.
Function definitions are just assignments
to global variables.
Data values in Lua are tagged to support
specialized extension by the host
application. Tags can be used to define
special handling for data types, or to
set up inheritance or delegation relationships.
There is only one implementation of Lua,
written in C. It is available free, in
source form, on
the web. The Lua reference manual is
W. Celes, R. Ierusalimschy, L.H. de Figueiredo, PUC-Rio, 1994.
- See Also:
Lua means "Moon" in Portuguese.
The Lua manual includes extensive information
on how to embed Lua in a host application,
and how to expose host data and functionality
to Lua scripts. Its interface for doing
this appears to be a little bit simpler
than the corresponding one for Tcl, and much
simpler than that of Perl.
However, Lua's complement of data types and
built-in functions is far smaller than
those of Tcl or Perl.
Lua has gone through several major
expansions in its fairly short career so far,
but new versions have maintained back-compatibility
with older ones.
The latest version, as of early 1998, was
- Sample code:
-- Simple Lua program that implements the
-- bisection method for solving non-linear equations
write(n," a=",a," fa=",fa," b=",b," fb=",fb,"\n")
if abs(a-b) < delta then return c end
if fa*fc < 0 then
-- find root of f in the inverval [a,b].
-- bisection requires that f(a)*f(b) < 0
delta=1e-6 -- tolerance
write(format("after %d steps, root is %.10g\n",n,z))
-- test the bisection code with
-- a function: x^3 - x - 1
return x*x*x - x - 1
Descriptions in this dictionary are ©1997-99 Neal Ziring. Some
examples copyright of their respective authors. Some
technologies and languages are trademarked. Permission to
copy descriptions is granted as long as authorship credit is preserved.
Comments on this dictionary, corrections and suggestions, are all welcome.
Please use email, the address is email@example.com
[Ziring MicroWeb Home]
Dictionary and script maintained by Neal Ziring, last major modifications 3/18/98. Most recent
additions to dictionary and master list, 1/00.