lua-users home
lua-l archive

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


On 10/16/2016 10:52 AM, Laurent FAILLIE wrote:

Is it possible to add a note in the given link to said it changed in next version ? (I'm still using Lua 5.1)


That is a link to the free on-line copy of PiL that is out of date in some details. It was written for Lua 5.0, and one of the biggest areas of change between 5.0 and 5.1 was in the module system. Best practices for modules have continued to evolve since then, while remaining generally backward compatible to Lua 5.1.

If you are heavily invested in a Lua 5.1 code base that won't be upgrading any time soon, I'd highly recommend finding a copy of the Second Edition of PiL which was updated specifically to track changes for Lua 5.1. It is apparently still available both in print and as an eBook. My print copy is well worn at this point.
  https://www.lua.org/pil/


Le Dimanche 16 octobre 2016 19h16, Hisham Muhammad <hisham.hm@gmail.com> a écrit :
On Oct 16, 2016 08:26, "Laurent FAILLIE" <l_faillie@yahoo.com> wrote:
>
> Hello,
>
> As per the documentation (https://www.lua.org/pil/8.1.html), global variable LUA_PATH ....


The true story for Lua 5.1 is in the reference manual, admittedly scattered about a bit since each of the moving parts has its own section.

The module system is covered by section 5.3.
  https://www.lua.org/manual/5.1/manual.html#5.3

The details of what the predefined package searchers do, and exactly where they look for information to guide their search is in the documentation of the package.loaders[] array where searchers live. The searcher that looks for modules on a path is in package.loaders[2].
  https://www.lua.org/manual/5.1/manual.html#pdf-package.loaders

The module path (for modules written in Lua, to be precise) is found in package.path, which is initialized from a compiled in default which can be replaced by an environment variable.
  https://www.lua.org/manual/5.1/manual.html#pdf-package.path

The large changes from 5.0 to 5.1 are documented in chapter 7, and the change to require and package.path is in 7.2.
  https://www.lua.org/manual/5.1/manual.html#7.2

-- 
Ross Berteig                               Ross@CheshireEng.com
Cheshire Engineering Corp.           http://www.CheshireEng.com/
+1 626 303 1602