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[, source[, mode[, env]]]) Load Lua code as a text or binary chunk.
setfenv (f) Get environment of a function.
setfenv (f, env) Set environment of a function

Lua 5.2 Functions Available for 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[, source[, mode[, env]]])
Load Lua code as a text or binary chunk.

Parameters:

  • ld code string or loader
  • source name of chunk for errors (optional)
  • mode 'b', 't' or 'bt' (optional)
  • env environment to load the chunk in (optional)
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 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.4.6 Last updated 2015-08-18 09:21:53