Skip to content

BenSiv/luam

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

97 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

# LuaM

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.

## Key Features

### 1. Safer Syntax
*   **mplicit Locals**: ariables are `local` by default. o need to type `local` everywhere.
    ```lua
    x = 10        -- Local variable
    function f()  -- Local function
    end
    ```
*   **mmutable by Default**: mplicitly declared variables are immutable. eassignment causes a compile-time error.
    ```lua
    x = 10
    x = 20 -- Error: attempt to assign to immutable variable
    ```
*   **Explicit Mutability**: Use the `mutable` keyword for variables that need to change.
    ```lua
    mutable y = 10
    y = 20 -- OK
    ```

### 2. Modern Operators & Control Flow
*   **nequality**: Use `!=` instead of `~=`.
    ```lua
    if x != y then ... end
    ```
*   **Else f**: Use `else if` instead of `elseif`.
    ```lua
    if x == 1 then
        ...
    else if x == 2 then
        ...
    end
    ```
*   **emoved Keywords**: `repeat`, `until`, and `local` have been removed to simplify the language. Use `while` loops instead.

### 3. Enhanced String & Data Support
*   **riple Quoted Strings**: Use `"""` for multiline strings (replacing `[[...]]`).
    ```lua
    s = """
    Multi-line
    String
    """
    ```
*   **Hexadecimal Escapes**: Use `\xXX` for characters in strings (e.g., `"\x41"` is "").
    ```lua
    str = "Lua\x4D" -- LuaM
    ```
*   **`__len` Metamethod**: ables support the `__len` metamethod (from Lua 5.2).
    ```lua
    mt = { __len = function(t) return 42 end }
    ```

### 4. mproved Standard Library
*   **`xpcall` with rguments**: `xpcall` now accepts arguments to pass to the function (from Lua 5.2).
    ```lua
    xpcall(func, handler, arg1, arg2)
    ```
*   **Unified `load`**: `load(chunk)` handles both functions (as `load` did) and strings (replacing `loadstring`).
    ```lua
    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 field `n`.
    *   `table.unpack(t)`: Unpacks a table (renamed from `unpack`, though global `unpack` remains).
*   **System & Packages**:
    *   `os.exit(boolean)`: Pass `true` (success) or `false` (failure).
    *   `package.searchers`: lias for `package.loaders` for 5.2 compatibility.

## Build & nstall

LuaM is implemented in strict S C (C89) and compiles on almost any platform.

### Building
Use `make` with your platform (e.g., `linux`, `macosx`, `posix`, `ansi`):

```sh
make linux
```

his will produce the binaries in `bld/`:
*   `bld/lua`: he interpreter
*   `bld/luac`: he compiler

### unning ests
o run the full regression suite:

```sh
make test
```

## License
LuaM is free software, released under the M license (same as Lua 5.1).
See [COPH](COPH) for details.

About

Minimal and Modernized Lua dialect.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published