Macro APILua Scripting
Language Reference
Supported Lua syntax and compiler exclusions.
Supported Subset
- locals and script-level globals
- if, elseif, else
- while and repeat loops
- numeric for loops
- generic for loops over pairs(t) or ipairs(t)
- break
- table constructors, dot indexing, and bracket indexing
- arithmetic, comparison, and logical operators
- .. string concatenation
- # length operator
- top-level named functions with recursion capped by call depth
- multiple assignment of value lists
Exclusions
| Feature | Diagnostic | Suggested alternative |
|---|---|---|
| Metatables | LUA_NO_METATABLES | Metatables are not supported in macros. |
| Coroutines | LUA_NO_COROUTINES | Coroutines are not supported in macros. |
| goto and labels | LUA_NO_GOTO | Goto and labels are not supported in macros. |
| Varargs | LUA_NO_VARARGS | Varargs are not supported in macros. |
| Closures and nested functions | LUA_NO_CLOSURES | Define functions at the top level of the script. |
| Multiple return values | LUA_NO_MULTI_RETURN | Multiple return values are not supported in macros. |
| String pattern APIs | LUA_NO_PATTERNS | Lua string pattern APIs are not supported in macros. |
| Method-call sugar | LUA_NO_METHOD_CALL | Use string.sub(s, ...) instead of s:sub(...). |
| Random number APIs | LUA_NO_RANDOM | Macros must be deterministic. |
| Host and environment APIs | LUA_NO_HOST | Host and environment APIs are not supported in macros. |
| Dynamic Macro API dispatch | LUA_DYNAMIC_API | Macro API functions must be called by static name. |
| Custom generic iterators | LUA_UNSUPPORTED_ITERATOR | Generic for loops must iterate with pairs(t) or ipairs(t). |