Module pl.compat

Lua 5.1/5.2 compatibility Ensures that `table.pack` and `package.searchpath` are available for Lua 5.1 and LuaJIT.

The exported function `load` is Lua 5.2 compatible. `compat.setfenv` and `compat.getfenv` are available for Lua 5.2, although they are not always guaranteed to work.

Functions

execute (cmd) execute a shell command.
load (ld, opt, opt, opt)
setfenv (f) Get environment of a function.
setfenv (f, env) Set environment of a function

Lua 5.2 Functions Available for Lua 5.1

table.pack (...) pack an argument list into a table.
package.searchpath (mod, path) return the full path where a Lua module name would be matched.


Functions

execute (cmd)
execute a shell command. This is a compatibility function that returns the same for Lua 5.1 and Lua 5.2

Parameters:

  • cmd a shell command

Returns:

  1. true if successful
  2. actual return code
load (ld, opt, opt, opt)

Parameters:

  • ld code string or loader
  • opt ] env environment to load the chunk in
  • opt ] env environment to load the chunk in
  • opt ] env environment to load the chunk in
setfenv (f)
Get environment of a function. With Lua 5.2, may return nil for a function with no global references! Based on code by [Sergey Rozhenko](http://lua-users.org/lists/lua-l/2010-06/msg00313.html)

Parameters:

  • f a function or a call stack reference
setfenv (f, env)
Set environment of a function

Parameters:

  • f a function or a call stack reference
  • env a table that becomes the new environment of `f`

Lua 5.2 Functions Available for Lua 5.1

Lua 5.2 Functions Available for Lua 5.1
table.pack (...)
pack an argument list into a table.

Parameters:

  • ... any arguments

Returns:

  1. a table with field n set to the length
  2. the length
package.searchpath (mod, path)
return the full path where a Lua module name would be matched.

Parameters:

  • mod module name, possibly dotted
  • path a path in the same form as package.path or package.cpath

see also:

generated by LDoc 1.3.12