Extrait du cours the virtual machine of lua 5.0
WHAT IS LUA ?
• Yet another scripting language
• Conventional syntax:
function fact (n)
if n == 0 then
return 1
else
return n * fact(n – 1)
end
end
function map (a, f)
local res = {}
for i, v in ipairs(a) do
res[i] = f(v)
end
return res
end
WHAT IS LUA ? ( CONT .)
• Associative arrays as single data structure
◦ first-class values
◦ any value allowed as index (not only strings)
◦ very efficient implementation
◦ syntactic sugar: a.x for a[« x »]
• Several not-so-conventional features
◦ first-class functions, lexical scoping, proper tail call, coroutines,
“dynamic overloading”
WHY LUA ?
• Light
◦ simple and small language, with few concepts
◦ core with approximately 60K, complete executable with 140K
• Portable
◦ written in “clean C”
◦ runs in PalmOS, EPOC (Symbian), Brew (Qualcomm), Playstation II, XBox, embedded systems, mainframes, etc.
• Efficient
◦ see benchmarks
• Easy to embed
◦ C/C++, Java, Fortran, Ruby, OPL (EPOC), C#
SOME APPLICATIONS
• Games
◦ LucasArts, BioWare, Microsoft, Relic Entertainment, Absolute Studios, Monkeystone Games, etc.
• Other Uses
◦ tomsrtbt – ”The most Linux on one floppy disk”
◦ Crazy Ivan Robot (champion of RoboCup 2000/2001 in Denmark)
◦ chip layouts (Intel)
◦ APT-RPM (Conectiva & United Linux)
◦ Space Shuttle Hazardous Gas Detection System (ASRC Aerospace)
VIRTUAL MACHINE
• Most virtual machines use a stack model
◦ heritage from Pascal p-code, followed by Java, etc.
………
Cours the virtual machine of lua 5.0 (210 KO) (Cours PDF)