LuaM is a modernized fork of Lua 5.1, featuring a stricter, safer, and more concise syntax. t retains the speed and simplicity of Lua 5.1 while adopting features from later Lua versions and modern programming paradigms.
- mplicit Locals: ariables are
localby default. o need to typelocaleverywhere.x = 10 -- Local variable function f() -- Local function end
- Constants: Use the
constkeyword to define immutable variables. Reassignment to aconstvariable results in a compile-time error.const y = 20 y = 30 -- Error: attempt to assign to const variable
- Inequality: Use
!=instead of~=.if x != y then ... end
- Removed Keywords:
repeat,until, andlocalhave been removed to simplify the language. Usewhileloops instead.
- riple Quoted Strings: Use
"""for multiline strings (replacing[[...]]).s = """ Multi-line String """
- Hexadecimal Escapes: Use
\xXXfor characters in strings (e.g.,"\x41"is "").str = "Lua\x4D" -- LuaM
__lenMetamethod: ables support the__lenmetamethod (from Lua 5.2).mt = { __len = function(t) return 42 end }
xpcallwith rguments:xpcallnow accepts arguments to pass to the function (from Lua 5.2).xpcall(func, handler, arg1, arg2)
- Unified
load:load(chunk)handles both functions (asloaddid) and strings (replacingloadstring).load("return 1") -- Works like loadstring
- Math & able Enhancements:
math.log(x, base): Supports optional base argument.table.pack(...): Creates a table from arguments with fieldn.table.unpack(t): Unpacks a table (renamed fromunpack, though globalunpackremains).
- System & Packages:
os.exit(boolean): Passtrue(success) orfalse(failure).package.searchers: lias forpackage.loadersfor 5.2 compatibility.
LuaM uses xmake as its build system.
To build LuaM, run:
xmake f -o bld -y
xmakeThis will produce all build artifacts (including intermediate files) in the bld/ directory:
bld/luam: The interpreterbld/luamc: The compilerbld/sqlite3.so: The SQLite3 module
To run the full regression suite:
xmake testThe doc directory contains detailed information about LuaM features and changes. Additionally, Unix manual pages are provided:
doc/lua.1: Manual page for theluaminterpreter.doc/luac.1: Manual page for theluamccompiler.
These can be viewed using man:
man doc/lua.1LuaM is free software, released under the M license (same as Lua 5.1). See COPYRIGHT.md for details.