lua-users home
lua-l archive

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


2014-06-26 8:13 GMT+02:00 Kalafut, Bennett <bennett.kalafut@thermofisher.com>:
> The surprise came largely because PIL, 3rd Edition's
> Lua equivalent of table.unpack() differed from the real table.unpack().
> The problem could be said to be with PIL.

Not only the 3rd Edition. <http://www.lua.org/pil/5.1.html>

function unpack (t, i)
      i = i or 1
      if t[i] ~= nil then
        return t[i], unpack(t, i + 1)
      end
    end

But is it really a problem with PiL?

PiL is not a Lua primer. One should read it only after one has read the
manual. It is full of clever tricks available from inside Lua itself, things
that Roberto knows but which you may not have discovered soon by
yourself. Such the above, which is a demonstration of the weird and
wonderful things you can do with multiple return values, in the chapter
on functions. The table library is discussed much further into the book.