Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
OO language targetting Lua
C Lua Other

This branch is 4 commits ahead, 94 commits behind master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
deps
editor
etc
lib
src
std
test
.gitmodules
Makefile
README.md
TODO.md

README.md

logo

NAME

Lupa - multi-paradigm object oriented, dynamic language

SYNOPSIS

lupa <file>
    run the script
lupa <file> -l
    list generated Lua

Lupa is an object-oriented language which targets the LuaJIT2 VM. It supports a rich feature set inspired by Ruby (property access via methods), Scala (operators are methods, traits), Perl 6 (has, method, does) and Falcon.

It also has some less commonly found features, such as parsing expression grammars (via LPeg) integrated into the language (instead of the traditional PCRE), and type guards.

Features

Most of Lua's semantics shine through, such as Lua's for loops, 1-based arrays, first-class functions, and late binding.

However, Lupa adds several features, such as:

  • classes with single inheritance
  • parameterisable traits and mixin composition
  • everything-is-an-object semantics
  • static symbol resolution
  • type guards and assertions
  • language integrated grammars (via LPeg)
  • operators as method calls
  • continue statement
  • string interpolation
  • builtin Array type
  • short function literals
  • switch-case statement
  • try-catch statement
  • and more...

Here's a sample:

trait Pet[T] {
  // parameterised traits with lexical scoping
  has size : T 
}

class Mammal {
  has blood = "warm"
}

trait Named {
  // default property values are lazy expressions
  has name = error("A pet needs a name!")
}

// single inheritance with trait mixins
class Hamster from Mammal with Pet[Number], Named {

  // default initializer
  method init(name) {
    self.size = 42
    .name = name // short for self.name = name
  }   

  method greet(whom : String) {
    // string interpolation
    print("Hi ${whom}, I am ${.name}!")
  }

  // class bodies have lexical scope
  var numbers = [ "one", "two", "three", "four", "five" ]

  method count(upto) {
    // short functions
    upto.times((_) => { print(numbers[_]) })

    // same thing, but `times' as infix operator
    upto times => print(numbers[_])
  }
}

var rudy = Hamster.new("Rudy")
rudy.greet("Jack")
rudy.count(5)

For more, check out:

Something went wrong with that request. Please try again.