lua-users home
lua-l archive

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

On Thu, Jul 2, 2009 at 12:03 PM, Thomas Lauer<> wrote:
> The Lua short reference provides a concise summary of the Lua syntax and
> core libraries. I have just updated and uploaded another draft of the
> 5.1 version. This can be downloaded from either the wiki:
> or from my website:
> A few small errors and inconsistencies were removed. However, there are
> certainly still errors and omissions to be found in this draft. PLEASE,
> everyone who uses this card -- take the time and trouble to send a bug
> report if you happen on something that needs correcting. (BTW, the
> exclusion of deprecated language features (like table.setn()) is by
> design.)
> Acknowledgements: Enrico Colombini (the original author) and I are
> grateful to all the good people who contributed with notes and
> suggestions, including John Belmonte, Albert-Jan Brouwer, Tiago
> Dionizio, Marius Gheorghe, Asko Kauppi, Philippe Lhoste, Mike Pall,
> Virgil Smith, Ando Sonenblick, Nick Trout, Clemens Wacha, Blake T.
> Garretson, mbp, James Salsman and of course Roberto Ierusalimschy, whose
> “Lua 5.1 Reference Manual” and “Programming in Lua” have been our main
> sources of Lua lore.
> --
> cheers  thomasl
> web :

Thank you for maintaining this, it is very useful having this kind of
"cheat-sheet", particularly for getting people who are good at programming but
just not that familiar with Lua yet up to speed quickly.

I have noticed a few things just skimming it now:
  - One of the table constructors {[-900] = 3, [+900] = 4} - Lua actually does
    not support the "unary plus" and throws a parse error at this.
  - Potential for confusion, maybe:

      x:move (2, -3)
      object call: shortcut for x.move(x, 2, -3), x will be assigned to self

    ..."x will be assigned to self", only if x.move was also created using the
    same syntax. Someone could misread this as 'whatever parameter was named
    "self", wherever it appears in the parameter list, will be set to x'.
  - setmetatable and setfenv returns the table/function, I don't know if you'd
    consider this worth mentioning in this but I find it quite useful
  - string.byte also allows two parameters to get the numerical code of each
    character in a range
  - Would it be worth mentioning how strings by default have a metatable set
    allowing for method calls that use the string table (and how you can use
    it on string literals only if you put them in parentheses)?