aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilipp Janda <siffiejoe@gmx.net>2015-04-25 21:34:17 +0200
committerPhilipp Janda <siffiejoe@gmx.net>2015-04-25 21:34:17 +0200
commitc4a98dafd07ed28e8f05d8771de65ce18ba0bee7 (patch)
tree4fce6a41b1ef2f96f59e3eca18e16141cef8abdd
parent67dd52ab4ee97cf644ed4540df14c9619b50d0af (diff)
downloadlua-compat-5.3-c4a98dafd07ed28e8f05d8771de65ce18ba0bee7.tar.gz
lua-compat-5.3-c4a98dafd07ed28e8f05d8771de65ce18ba0bee7.tar.bz2
lua-compat-5.3-c4a98dafd07ed28e8f05d8771de65ce18ba0bee7.zip
Document changes to compat53.module in readme.
-rw-r--r--README.md29
1 files changed, 10 insertions, 19 deletions
diff --git a/README.md b/README.md
index f75c8fc..9b14208 100644
--- a/README.md
+++ b/README.md
@@ -45,27 +45,18 @@ versions of the new `table` functions are used as a fallback, and
45#### Lua submodules 45#### Lua submodules
46 46
47```lua 47```lua
48local compat53 = require("compat53.base") 48local _ENV = require("compat53.module")
49if setfenv then setfenv(1, _ENV) end
49``` 50```
50 51
51This loads the compatibility functions and returns them in a table 52The `compat53.module` module does not modify the global environment,
52without modifying the global environment. The returned table has a 53and so it is safe to use in modules without affecting other Lua files.
53metatable set so that lookup of unmodified global functions should 54It is supposed to be set as the current environment (see above), i.e.
54work as well. Some features (e.g. file methods) of `compat53` only 55cherry picking individual functions from this module is expressly
55take effect when applied to the global environment though, and groups 56*not* supported!). Not all features are available when using this
56of functions might be interdependent and should not be mixed with old 57module (e.g. yieldable (x)pcall support, string/file methods, etc.),
57versions of those functions. (I.e. it is recommended to use plain 58so it is recommended to use plain `require("compat53")` whenever
58`require("compat53")` when possible!) 59possible.
59
60```lua
61require("compat53.module")
62```
63
64This looks in the call stack for the closest "main" chunk (module or
65script) and replaces its environment so that you can transparently use
66the compatibility functions in this file alone without affecting other
67files. The same gotchas as for `"compat53.base"` apply. Additionally
68this relies on the availability of `debug` functions.
69 60
70### C code 61### C code
71 62