Skip to content

Latest commit

 

History

History
82 lines (62 loc) · 4 KB

index.md

File metadata and controls

82 lines (62 loc) · 4 KB

Mobius Documentation

Mobius is a type-inferred scripting language designed to be embedded in C and C++ applications. Variables are type-locked — a variable's type is inferred from its first non-nil assignment and cannot change — which lets the bytecode VM emit type-specialized opcodes and skip runtime type checks on the hot path. Mobius takes inspiration from Lua and adds type locking, enums, a rich switch with pattern matching, fibers with channels, and a familiar C-style syntax.

Source files use the .mob extension.

enum Suit { CLUBS, DIAMONDS, HEARTS, SPADES }

func describe(card) {
    switch (card.rank) {
        case 1:        return "Ace"
        case 11..13:   return "Face card"
        default:       return str(card.rank)
    }
}

var card = { rank: 12, suit: Suit.HEARTS }
print(describe(card))    // "Face card"

Where to start

If you want to… Read
Build Mobius and run your first script Getting Started
See the whole language in one page Language Tour
Learn the language in depth The Guide pages below
Look up a built-in function Standard Library
Use a bundled module (json, os, http, …) Module Reference
Embed Mobius in a C/C++ program Embedding Guide
Write a native plugin module Plugin Guide
Read the exact grammar Grammar (BNF)

Guide

A progressive tour of the language. Each page builds on the last, but they also stand alone as references for a single topic.

  1. Getting Started — build, run, the REPL, the CLI, and your first program
  2. Language Tour — a fast, example-driven overview of everything
  3. Values and Types — type locking, annotations, literals, conversions
  4. Control Flow — if/while/for and the pattern-matching switch
  5. Functions — declarations, annotations, first-class values, closures
  6. Error Handling — throw, try/catch/finally
  7. Collections — arrays, tables, metatables, OOP patterns, enums
  8. Binary Data — buffers and struct views over raw memory
  9. Concurrency — fibers, spawn/await, shared, atomic, channels
  10. Modules and Packages — import, load, and installable packages

Reference

Embedding & Extending

  • Embedding Guide — run Mobius from C/C++, exchange values, register functions
  • Plugin Guide — author native .so/.dll modules
  • Packaging — module.yaml and the .mz package format

Project status

See the roadmap for proposed work that hasn't landed yet: file watching, a CSV module, bundles without extraction, TLS and a data package.

Mobius is at version 0.2.3. The language, VM, standard library, fiber runtime, embedding API, and the bundled modules are usable today. The package manager (.mz archives) and several modules (http, socket, websocket) are explicitly plain-transport-only for now — TLS is not yet included.