Home

Awesome

l2l

This language is a superset of Lisp and Lua.

Example

boolean.lisp, implements and, or special forms:

@import quasiquote
@import quote
@import fn
@import local
@import do
@import let
@import cond

(fn circuit_and (invariant cdr output truth)
  (cond cdr
    (let (
      car (:car cdr)
      ref (lua_name:unique "_and_value"))
      `\
        local \,ref = \,\(expize(invariant, car, output))
        if \,ref then
          \,(cond (:cdr cdr)
              (circuit_and invariant (:cdr cdr) output truth)
              `\\,truth = \,ref)
        else
          \,truth = false
        end)))

(fn expize_and (invariant cdr output)
  (let (ref (lua_name:unique "_and_bool"))
    (table.insert output `\local \,ref = true)
    (table.insert output (circuit_and invariant cdr output ref))
    ref))

(fn statize_and (invariant cdr output)
  (to_stat (expize_and invariant cdr output)))

(fn circuit_or (invariant cdr output truth)
  (cond cdr
    (let (
      car (:car cdr)
      ref (lua_name:unique "_or_value"))
      `\
        if not \,truth then
          local \,ref = \,\(expize(invariant, car, output))
          if \,ref then
            \,truth = \,ref
          end
        end
        \,(cond (:cdr cdr)
            (circuit_or invariant (:cdr cdr) output truth)))))

(fn expize_or (invariant cdr output)
  (let (ref (lua_name:unique "_or_bool"))
    (table.insert output `\local \,ref = false)
    (table.insert output (circuit_or invariant cdr output ref))
    ref))

(fn statize_or (invariant cdr output)
  (to_stat (expize_or invariant cdr output)))

{
  lua = {
    ["and"] = {expize=expize_and, statize=statize_and},
    ["or"] = {expize=expize_or, statize=statize_or}
  }
}

Quick Start

# Requires https://github.com/meric/leftry cloned as a sibling to this repo.
git clone git@github.com:meric/leftry.git
git clone git@github.com:meric/l2l.git
cd l2l
make clean
make test
make repl

Run the following commands:

> (print "hello world")
hello world
> \print("hello world")
hello world
> (let (a 1) (print `\print(\,a)))
print(1)
> (let (a 1) (print (getmetatable `\print(\,a))))
lua_block

Syntax Highlighting

l2l-syntax-highlighting

Naming

Lisp names are mangled into Lua by replacing non lua compliant characters with lua compliant characters. (See the mangle function in l2l/reader.lua).

Lisp names can contain dashes, dots, alphabets, numbers, underscores, and many more characters, but they must not consist of two dots consecutively unless the name is .. (lua string concat) or ... (lua vararg).

This is so the compiler can mangle lua field accessor names my_table.my_subtable-with-dashes.some_key properly.

Features

Philosophy

The Tao begot one. One begot two.<br>Laozi

Now I do not know whether I was then a man dreaming I was a butterfly,<br> Or whether I am now a butterfly, dreaming I am a man.<br>Zhuangzi

I have put duality away, I have seen that the two worlds are one;<br> One I seek, One I know, One I see, One I call.<br>Jalaluddin Rumi

Now I do not know whether I was writing Lua inside of Lisp,<br> Or whether I am now writing Lisp, inside of Lua.<br> I have put duality away, I have seen that the two worlds are one;<br> One I read. One I write. One I compile. One I run.<br>You

Obligatory

I am the servant of the Qur'an as long as I have life.<br> I am the dust on the path of Muhammad, the Chosen one.<br> If anyone quotes anything except this from my sayings,<br> I am quit of him and outraged by these words.<br>Jalaluddin Rumi