lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Hello Lua-list,

The following comments and suggestions have been collected while reading
the excellent book "Programming in Lua, Fourth edition" by Roberto
Ierusalimschy (PiL 4) that deals primarily with Lua 5.3:

1.  Page xvii: "command-line interface in a window" -> "command-line
    interface in one window".

2.  Page 3: "should run it:" -> "should run it (% is the command
    prompt):".

3.  Page 3: "% lua hello.lua" -> "% lua hello.lua --> Hello World".

4.  Page 3: The factorial example uses io.read("*n"), but the asterisk
    is not really Lua 5.3 (see the note on page 60), so perhaps
    io.read("n") is better.

5.  Page 3: Following the factorial code: "Example of running this
    program in file factorial.lua:

      % lua factorial.lua
      enter a number:
      4
      24"

6.  Page 6: "A comment starts anywhere" -> "A comment starts anywhere
    outside strings".

7.  Page 6: "(which I hardly do)" -> "(which I rarely do)".

8.  Page 7: To the list of type() examples, add
    "type(coroutine.create(function() end)) --> thread".

9.  Pages 7-9: The section "1.4 Types and Values" has a detailed
    discussion of selected types, postponing the discussion of other
    types. This causes what I feel is an unfortunate change of focus,
    back and forth. Referring to Programming in Lua, 3rd edition (PiL
    3), the description there in "2 Types and Values" seems much more
    coherent.

10. Page 13: "position eight queens in" -> "position eight queens on".

11. Page 13: To the first paragraph, add: "By the rules of chess, a
    queen can move up and down, left and right, and diagonally."

12. Page 15: "queens larger than or equal to n in the board" -> "queens
    in column n or larger on the board".

13. Page 17: "in more detail the incompatibilities" -> "the
    incompatibilities in more details".

14. Page 21: "If the values have different types ... Otherwise, Lua
    compares them according to their types": What this latter statement
    actually means is not entirely clear. The index reference of
    "relational operators" to page 20 and 189 doesn't really help. The
    section "3.2 Relational Operators" in PiL 3 explains how strings and
    values of other types are compared, something useful that I have not
    been able to find in PiL 4.

15. Page 23: "signal bit" -> "sign bit".

16. Page 25: The section "3.7 Precedence" mentions a number of operators
    for the first time as far as I can tell. To be sure, a reference is
    made, in a footnote, to a later description of bitwise operators.
    But the length operator # and the concatenation operator .. are here
    mentioned, but only described later (page 29/43 and page 30,
    respectively). And, just to make sure, this is chapter "3 Numbers".
    The corresponding part of PiL 3 (section "3.6 Precedence" pages
    25-26 in chapter "3 Expressions") is much more coherent.

17. Page 35: "replaced by a formatted version of its correspondent
    argument": The correspondence between the formatting directives in
    the format string and the list of arguments that follow the format
    string should be described more firmly, for example by "The i'th
    formatting directive corresponds to the i'th of the arguments that
    follow the format argument".

18. Page 35: "based on pattern matching" -> "that perform pattern
    matching".

19. Page 37: "it returns false" -> "it returns nil".

20. Page 37: The utf8.len() examples could advantageously be extended
    with some examples that use # on the same string for which
    utf8.len() is reported. For example "> # "résumé" --> 8".

21. Page 44: "and that is has a hole" -> "and that it has a hole" ("is"
    -> "it").

22. Page 46: "Granted ... substitute.": Excellent.

23. Page 51: "A multiple assignment ...": In PiL 3, section "4.1
    Assignment" describes assignment, including the multiple variant. I
    miss a similar description of assignment in PiL 4. It is even
    missing from the index.

24. Page 60: "it also can hide subtle bugs" -> "it can also hide subtle
    bugs".

25. Page 61: "-- read the lines in" -> "-- read the lines into".

26. Page 86: The function rect's parameter "up" -> "top".

27. Page 91: At end of section "The function string.gsub", add the
    example

      string.gsub("xyzzy","y","q") --> xqzzq	2

28. Page 91: "escape character in Lua" -> "escape character in Lua
    strings".

29. Page 96: "In particular" -> "As a special case".

30. Page 112: The out-of-line placement of "Listing 12.1. Directives for
    function os.date:": It takes some effort to (re-)discover that the
    sample values shown in this table is for "September 16, 1998 (a
    Wednesday), at 23:48:10" as we are explained on page 111. The PiL 3
    in-line placement of this table is more helpful.

31. Page 113: "subtracting on time" -> "subtracting one time".

32. Page 116: "fill with zeroes the vacant bits" -> "fill the vacant
    bits with zeroes".

33. Page 118: "in a value greater than" -> "to a value greater than".

34. Page 119: "integer larger enough" -> "integer large enough".

35. Page 121: "during the translation" -> "during the conversion".

36. Page 126: "not uncommon data description files" -> "not uncommon to
    encounter data description files".

37. Page 151: "$ luac" -> "% luac" (twice).

38. Page 154: Following "The function pcall ... running.", add
    "Subsequent arguments are passed to the called function."

39. Page 160: "For it" -> "As far as require is concerned".

40. Page 160: "a table comprising" -> "a table containing".

41. Page 160: "this action is done" -> "this value is generated".

42. Page 162: "require strips from the name its suffix after the hyphen"
    -> "require uses only the prefix of the name before the hyphen"

43. Page 163: "useless long strings" -> "needlessly long strings".

44. Page 165: Following "nice technique to detect global variables
    created by mistake", add "(see page 220)".

45. Page 171: "over a subject" -> "over a string".

46. Page 173: "in the next code" -> "in the following code".

47. Page 188: "print(Set.tostring((s1 + s2)*s1)) --> {10, 20, 30, 50}"
    -> "print(Set.tostring((s1 + s2)*Set.new{1, 20, 30, 60})) --> {1,
    20, 30}".

48. Page 241: The line "producer = coroutine.create( producer )"
    confuses me every time I read it and seems an unfortunate practice
    to illustrate. I like the version in PiL 3 that simply includes the
    complete producer code as argument to coroutine.create() much
    better. This is, of course, also what happens in the accompanying
    listing 24.1.

49. Page 252: I Suggest that both currentline and istailcall be given a
    suitable mention in the list of fields of the table returned by
    debug.getinfo().

50. Page 253: "'u' selects nup" -> "'u' selects nups".

51. Page 253: To the table of selection characters, add "'t' selects
    istailcall".

52. Page 253: Extend the debug.traceback() example on the bottom of the
    page by:

      > function g() print(debug.traceback()) end function f() g() end f()
      stack traceback:
      	stdin:1: in function 'g'
      	stdin:1: in function 'f'
      	stdin:1: in main chunk
      	[C]: in ?

53. Page 267: "function receive": I suggest using a name for this
    function that doesn't match the "connection:receive" method.

54. Page 290: "getenv" -> "os.getenv".

55. Page 312: "push that sting" -> "push that string".

56. Page 337: "take a user data" -> "take a userdata".

57. Page 340: The function lua_setuservalue() is not mentioned in the
    index. It appears that the index, although quite comprehensive,
    doesn't mention things in listings. On the other hand, the fact that
    lua_setuservalue is not in the index, may indicate that it is not
    mentioned in the text, which is perhaps unfortunate.

58. Page 363: "lua_tointegerx .. 290" -> "lua_tointegerx .. 279, 290".

59. Page 363: Add "lua_tonumberx .. 279".

60. Page 365: "ipairs .. 45, 71, 171, 174, 175, 177" -> "ipairs .. *45*,
    71, 171, 174, 175, 177". PiL 3 uses bold page numbers in the index
    for emphasis which is quite valuable. So this is just one instance
    where such emphasis would improve the index.

61. Page 365: "length operator .. 29," -> "length operator .. 25, 29,".

Best regards
Thorkil