diff options
author | Philipp Janda <siffiejoe@gmx.net> | 2015-04-12 00:15:22 +0200 |
---|---|---|
committer | Philipp Janda <siffiejoe@gmx.net> | 2015-04-12 00:15:22 +0200 |
commit | a4bdca7201500538835baefb81e193f8134989d2 (patch) | |
tree | 1a6c3d88b8563f9be70d9e7e0ef1f894a056ed1a | |
parent | ddeb3f7a1e25667694eaf3c8bf639b66d6809cb4 (diff) | |
download | lua-compat-5.3-a4bdca7201500538835baefb81e193f8134989d2.tar.gz lua-compat-5.3-a4bdca7201500538835baefb81e193f8134989d2.tar.bz2 lua-compat-5.3-a4bdca7201500538835baefb81e193f8134989d2.zip |
document new submodules
-rw-r--r-- | README.md | 27 |
1 files changed, 26 insertions, 1 deletions
@@ -42,6 +42,31 @@ string packing modules automatically. If unsuccessful, pure Lua | |||
42 | versions of the new `table` functions are used as a fallback, and | 42 | versions of the new `table` functions are used as a fallback, and |
43 | [Roberto's struct library][1] is tried for string packing. | 43 | [Roberto's struct library][1] is tried for string packing. |
44 | 44 | ||
45 | #### Lua submodules | ||
46 | |||
47 | ```lua | ||
48 | local compat53 = require("compat53.base") | ||
49 | ``` | ||
50 | |||
51 | This loads the compatibility functions and returns them in a table | ||
52 | without modifying the global environment. The returned table has a | ||
53 | metatable set so that lookup of unmodified global functions should | ||
54 | work as well. Some features (e.g. file methods) of `compat53` only | ||
55 | take effect when applied to the global environment though, and groups | ||
56 | of functions might be interdependent and should not be mixed with old | ||
57 | versions of those functions. (I.e. it is recommended to use plain | ||
58 | `require("compat53")` when possible!) | ||
59 | |||
60 | ```lua | ||
61 | require("compat53.module") | ||
62 | ``` | ||
63 | |||
64 | This looks in the call stack for the closest "main" chunk (module or | ||
65 | script) and replaces its environment so that you can transparently use | ||
66 | the compatibility functions in this file alone without affecting other | ||
67 | files. The same gotchas as for `"compat53.base"` apply. Additionally | ||
68 | this relies on the availability of `debug` functions. | ||
69 | |||
45 | ### C code | 70 | ### C code |
46 | 71 | ||
47 | There are two ways of adding the C API compatibility functions/macros to | 72 | There are two ways of adding the C API compatibility functions/macros to |
@@ -67,7 +92,7 @@ your project: | |||
67 | 5.3 sources or from the `struct` module. (`struct` is not 100% | 92 | 5.3 sources or from the `struct` module. (`struct` is not 100% |
68 | compatible to Lua 5.3's string packing!) (See [here][4]) | 93 | compatible to Lua 5.3's string packing!) (See [here][4]) |
69 | * `math.maxinteger` and `math.mininteger`, `math.tointeger`, `math.type`, | 94 | * `math.maxinteger` and `math.mininteger`, `math.tointeger`, `math.type`, |
70 | and `math.ult` (See [here][5] | 95 | and `math.ult` (see [here][5]) |
71 | * `ipairs` respects `__index` metamethod | 96 | * `ipairs` respects `__index` metamethod |
72 | * `table.move` | 97 | * `table.move` |
73 | * `table` library respects metamethods | 98 | * `table` library respects metamethods |