Upload
alexandra-anderson
View
215
Download
1
Tags:
Embed Size (px)
Citation preview
History• Made by Roberto Ierusalimschy, Luiz
Henrique de Figueiredo, and Waldemar Celes in 1993
• Members of Tecgraf, PUC-Rio in Brazil
• Brazil had trade barriers making it hard to buy software from abroad
Release TimelineJul 1993 - Lua 1.0Jul 1994 - Lua 1.1 (first public release), paperFeb 1995 - Lua 2.1 (first free commercial release)Nov 2000 - Lua 4.0, no built-in functionsApr 2003 - Lua 5.0, multithreading, full lexical scoping
Dec 2011 - Lua 5.2, current version
Language Influences• Replaces
o DEL (data-entry language)o SOL (simple object language)
• Scheme
• Modula
Resourceswww.lua.orgwww.lua-users.orgcode.google.com/p/luaforwindows
luadist.orgPlugins for most popular IDEs
Function• High-level scripting language
• Lightweight - interpreter about 180k
• Embedded language - C API
Execution• Interpreter compiles to bytecode for
Lua VM
• Very fast, usually compiled at run-time
• Programs can be compiled in advance to skip overhead
• Portable, builds on anything with a C compiler
Paradigms• Multi-paradigm
• Imperative
• Functional
• Not object-oriented, but object-like constructs can be made using tables and metatables
Reserved Keywords• and
• break
• do
• else
• elseif
• end
• false
• for
• function
• goto
• if
• in
• local
• nil
• not
• or
• repeat
• return
• then
• true
• until
• while
Assignment• “multiple” assignment
o a, b, c = “this is multiple assignment”, “yep” i.e. a = “this is multiple assignment”, b = “yep”, c = nil
o a, b = b, a a and b have swapped values
o a = a or b if not a, a = b
Typing and scope• Strongly typed
• Dynamic typing
• local keyword specifies non-globals
• Symbol table easily accessible
Metatables• None by default,
added with setmetatable
• Metamethods include:o addo subo mulo divo modo powo unm
o concato len
o eqo lto leo indexo newindexo call
Closures• a function inside of a function
• inner function has access to local variables of the outside function
Object-oriented Features• No classes, only prototypes
• Syntactic sugar for methods:
function table.func(self, args)
can be written as
table:func(args)
Application Areas• GAMING
• Notables include World of Warcraft, FarCry, the CryENGINE2,
Garry’s Mod, Angry Birds
References• The Evolution of Lua
• Programming in Lua, first Edition