Lua Programming in Lua – errata

Third edition

page 13, second line reported by Martin BŁttner
\x\hh should be \xhh
page 35, fifth line reported by Tony Booer
"basic Lua library>" should be "basic Lua library."
page 37, first code snippet reported by Lorenzo Donati
else if ... should be elseif ...
page 59, exercise 6.1 reported by Jan SedlŠk
The description of the problem is not very precise. It should read like this:

"Write a function integral that receives a function f and returns its definite integral function. This returned function, when given two values a and b, returns an approximation of the integral of f from a to b"

page 66, second paragraph
There is this note:

"As we already mentioned, linked lists are not frequent in Lua, but sometimes we need them."

However, the book did not mention linked lists before this point.

page 99, first code fragment in section 10.2 reported by Tomas Guisasola
allwords should be allwords() (a function call).
page 131, second-to-last line reported by Martin BŁttner
__leq should be __le
page 147 reported by Peter Kazmier
"We can load it whit" should be "We can load it with"
page 152, third code fragment reported by Claudio Morgado
local f = should be local f =
page 158, listing 15.2 reported by Tony Booer
local i =, 1) should be local i = new(0, 1)
page 177, title of section 17.2
The word "Memoize" (instead of "Memorize") is used on purpose, to refer to the term "Memoization" (which means "Memorization", but it is already established).
page 183, last line reported by Pete Hollobon
"anchors it" should be "anchor it"
page 184, first paragraph reported by Pete Hollobon
"make the finalizer creates" should be "make the finalizer create"
page 192, last code fragment reported by Martin BŁttner
if bit32.or(a, b) == bit32.or(-1) then

should be

if bit32.bor(a, b) == bit32.bor(-1) then

page 198, exercise 20.1 reported by Patrick
There is a missing closing parenthesis in the print statement.
page 213, in function unexpandTabs reported by Tomas Guisasola
s = expandTabs(s) should be s = expandTabs(s, tab)
page 217, fourth paragraph reported by Ana Lķcia de Moura
"multi-line sequences" should be "multi-byte sequences"
page 225, sixth paragraph reported by Lorenzo Donati
Contrary to what the book says, io.lines cannot accept a file handle as its first argument.
page 226, listing 22.1 reported by Lorenzo Donati
The following line should be removed, as it is useless:

local f = io.input(arg[1]) -- open input file

page 226, last paragraph
The observation "as long as the pattern does not contain a zero byte" does not apply to Lua 5.2. Lua 5.2 handles zero bytes in patterns without problems.
page 234, last code fragment reported by Daniele Kazan
loadstring should be load
page 282, third-to-last paragraph reported by Martin BŁttner
lua_pcall should be lua_call
page 292, exercises 28.4 and 28.6 reported by Daniele Kazan
"tranliterate" should be "transliterate"
page 323, section 31.2 reported by Andrew Starks
There are a few errors in the code for the library lproc described in this section: a few missing #includes and the use of two deprecated entities, luaL_reg and luaL_register. See the correct code for the complete example.

Second edition

No errata available.

First edition

See this page for the errata for the printed version.
All corrections listed in the errata have been made in the online version.