Skip to content
Documentation for Lunar's syntax and semantics
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

Lunar Language Specification

Lunar is a superset programming language of Lua 5.1, which means it inherits all of Lua 5.1's syntax and semantics. Nothing in Lunar should work any differently if it compiled existing Lua 5.1 code.

Check out the code examples on the bottom of this readme.

ATTENTION: Lunar is still early in development! All syntax listed below is subject to changes until v1 release, in which case it will never be changed.

Disclaimer: Existing syntaxes are always a candidate for changes, even if it's a breaking change. We will try our best to document them.


Classes, the staple of object-oriented programming, is implemented in Lunar.

-- unfortunately no syntax highlighting for lunar yet, so we'll stick with lua
class Account
  constructor(name, balance) = name
    self.balance = balance or 0

  function deposit(credit)
    self.balance += credit

  function withdraw(debit)
    self.balance -= debit

local account ="Jeff Bezos", 500)
print(account.balance) --> 500
print(account.balance) --> 750
print(account.balance) --> 450

Lunar adds 7 new operators: ..=, +=, -=, *=, /=, ^=, and %=.

local message = "hello"
message ..= " world!"
print(message) --> "hello world!"

local a, b = 1, 2
a, b += 1, 2
print(a, b) --> 2, 4

Lunar also adds lambda expressions making it more convenient to create short and quick functions as well as big functions.

local divisible = |dividend, divisor| dividend % divisor == 0
local fizz = |n| do
  local message = ""

  if divisible(n, 3) then message ..= "Fizz" end
  if divisible(n, 5) then message ..= "Buzz" end
  if message == "" then message = n end

  return message

for i = 1, 100 do
You can’t perform that action at this time.