{"id":13647585,"url":"https://github.com/meric/l2l","last_synced_at":"2025-04-22T02:32:09.892Z","repository":{"id":139107936,"uuid":"3274025","full_name":"meric/l2l","owner":"meric","description":"Lisp is Lisp. Lua is Lua. Lisp and Lua as One.","archived":false,"fork":false,"pushed_at":"2017-10-16T14:02:17.000Z","size":792,"stargazers_count":306,"open_issues_count":4,"forks_count":15,"subscribers_count":19,"default_branch":"master","last_synced_at":"2024-11-09T21:37:08.435Z","etag":null,"topics":["lisp","lisp-compiler","lisp-dialect","lua"],"latest_commit_sha":null,"homepage":"","language":"Lua","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/meric.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2012-01-26T13:38:35.000Z","updated_at":"2024-06-08T17:08:29.000Z","dependencies_parsed_at":"2024-01-14T10:23:06.545Z","dependency_job_id":"d5630c75-a321-471c-a6e8-c053b4fba99e","html_url":"https://github.com/meric/l2l","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/meric%2Fl2l","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/meric%2Fl2l/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/meric%2Fl2l/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/meric%2Fl2l/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/meric","download_url":"https://codeload.github.com/meric/l2l/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250163734,"owners_count":21385300,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["lisp","lisp-compiler","lisp-dialect","lua"],"created_at":"2024-08-02T01:03:39.711Z","updated_at":"2025-04-22T02:32:09.620Z","avatar_url":"https://github.com/meric.png","language":"Lua","readme":"# l2l #\n\nThis language is a superset of Lisp and Lua.\n\n## Example ##\n\n[boolean.lisp](/l2l/ext/boolean.lisp), implements `and`, `or` special forms:\n\n```lua\n@import quasiquote\n@import quote\n@import fn\n@import local\n@import do\n@import let\n@import cond\n\n(fn circuit_and (invariant cdr output truth)\n  (cond cdr\n    (let (\n      car (:car cdr)\n      ref (lua_name:unique \"_and_value\"))\n      `\\\n        local \\,ref = \\,\\(expize(invariant, car, output))\n        if \\,ref then\n          \\,(cond (:cdr cdr)\n              (circuit_and invariant (:cdr cdr) output truth)\n              `\\\\,truth = \\,ref)\n        else\n          \\,truth = false\n        end)))\n\n(fn expize_and (invariant cdr output)\n  (let (ref (lua_name:unique \"_and_bool\"))\n    (table.insert output `\\local \\,ref = true)\n    (table.insert output (circuit_and invariant cdr output ref))\n    ref))\n\n(fn statize_and (invariant cdr output)\n  (to_stat (expize_and invariant cdr output)))\n\n(fn circuit_or (invariant cdr output truth)\n  (cond cdr\n    (let (\n      car (:car cdr)\n      ref (lua_name:unique \"_or_value\"))\n      `\\\n        if not \\,truth then\n          local \\,ref = \\,\\(expize(invariant, car, output))\n          if \\,ref then\n            \\,truth = \\,ref\n          end\n        end\n        \\,(cond (:cdr cdr)\n            (circuit_or invariant (:cdr cdr) output truth)))))\n\n(fn expize_or (invariant cdr output)\n  (let (ref (lua_name:unique \"_or_bool\"))\n    (table.insert output `\\local \\,ref = false)\n    (table.insert output (circuit_or invariant cdr output ref))\n    ref))\n\n(fn statize_or (invariant cdr output)\n  (to_stat (expize_or invariant cdr output)))\n\n{\n  lua = {\n    [\"and\"] = {expize=expize_and, statize=statize_and},\n    [\"or\"] = {expize=expize_or, statize=statize_or}\n  }\n}\n```\n\n## Quick Start ##\n\n```bash\n# Requires https://github.com/meric/leftry cloned as a sibling to this repo.\ngit clone git@github.com:meric/leftry.git\ngit clone git@github.com:meric/l2l.git\ncd l2l\nmake clean\nmake test\nmake repl\n```\n\nRun the following commands:\n\n```\n\u003e (print \"hello world\")\nhello world\n\u003e \\print(\"hello world\")\nhello world\n\u003e (let (a 1) (print `\\print(\\,a)))\nprint(1)\n\u003e (let (a 1) (print (getmetatable `\\print(\\,a))))\nlua_block\n```\n\n## Syntax Highlighting ##\n\n![l2l-syntax-highlighting](/l2l-syntax-highlight.png?raw=true \"\")\n\n* [Atom: language-l2l](https://atom.io/packages/language-l2l)\n* [Sublime Text: l2l.sublime-package](https://github.com/meric/l2l.sublime-package)\n\n## Naming ##\n\nLisp names are mangled into Lua by replacing non lua compliant characters\nwith lua compliant characters. (See the mangle function in l2l/reader.lua).\n\nLisp names can contain dashes, dots, alphabets, numbers, underscores, and many\nmore characters, but they must not consist of two dots consecutively unless\nthe name is `..` (lua string concat) or `...` (lua vararg).\n\nThis is so the compiler can mangle lua field accessor names\n`my_table.my_subtable-with-dashes.some_key` properly.\n\n## Features ##\n\n* Mix Lisp and Lua in source code with backslash.\n\n  ```lua\n  \\print(\\(+ 1 2 3 4))\n  ```\n\n* Quasiquoting Lua expressions.\n\n  ```lua\n  (table.insert output `\\local \\,ref = false)\n  ```\n\n* Macro and special form aliasing.\n* Macro as modules.\n\n  ```lisp\n  @import (let x); (x.let (y 1) (print y))\n  ```\n\n* Custom special forms as modules.\n\n  For example, [boolean.lisp](/l2l/ext/boolean.lisp).\n\n* Zero-cost `map`, `filter`, `reduce` abstractions. \u003ca id=\"zero-cost\"\u003e\u003c/a\u003e\n* Implement special forms that can inline anonymous functions as macros.\n* Special forms in Lua.\n\n  ```lua\n  @import iterator\n  \\\n  map(function(x) return x + 2 end,\n    filter(function(x) return x % 2 == 0 end,\n      map(function(x) return x + 1 end, {1, 2, 3, 4})))\n  ```\n\n  Compiles into (nested loops collapsed into a single pass):\n\n  ```lua\n  local ipairs = require(\"l2l.iterator\")\n  local vector = require(\"l2l.vector\")\n  local next38,invariant37,i39 = ipairs({1,2,3,4});\n  local values41 = vector();\n  while i39 do\n    local v40;i39,v40=next38(invariant37,i39);\n    if i39 then\n      v40=v40 + 1;\n      if v40 % 2 == 0 then\n        v40=v40 + 2;\n        (values41):insert(v40)\n      end\n    end\n  end\n  return values41\n  ```\n\n## Philosophy ##\n\n\u003e The Tao begot one. One begot two.\u003cbr\u003e\n\u003e \u0026mdash; *[Laozi](http://terebess.hu/english/tao/gia.html#Kap42)*\n\n\u003e Now I do not know whether I was then a man dreaming\n\u003e I was a butterfly,\u003cbr\u003e\n\u003e Or whether I am now a butterfly, dreaming I am a man.\u003cbr\u003e\n\u003e \u0026mdash; *[Zhuangzi](http://ctext.org/zhuangzi/adjustment-of-controversies?searchu=butterfly\u0026searchmode=showall#result)*\n\n\u003e I have put duality away, I have seen that the two worlds are one;\u003cbr\u003e\n\u003e One I seek, One I know, One I see, One I call.\u003cbr\u003e\n\u003e \u0026mdash; *[Jalaluddin Rumi](http://thefoggiestnotion.com/rumi.htm)*\n\n\u003e Now I do not know whether I was writing Lua inside of Lisp,\u003cbr\u003e\n\u003e Or whether I am now writing Lisp, inside of Lua.\u003cbr\u003e\n\u003e I have put duality away, I have seen that the two worlds are one;\u003cbr\u003e\n\u003e One I read. One I write. One I compile. One I run.\u003cbr\u003e\n\u003e \u0026mdash; *[You](http://www.thoughtpursuits.com/10-faciniting-love-poems-rumi/)*\n\n\n#### Obligatory ####\n\n\u003e I am the servant of the Qur'an as long as I have life.\u003cbr\u003e\n\u003e I am the dust on the path of Muhammad, the Chosen one.\u003cbr\u003e\n\u003e If anyone quotes anything except this from my sayings,\u003cbr\u003e\n\u003e I am quit of him and outraged by these words.\u003cbr\u003e\n\u003e \u0026mdash; *[Jalaluddin Rumi](https://en.wikipedia.org/wiki/Rumi)*\n","funding_links":[],"categories":["Lua"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmeric%2Fl2l","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmeric%2Fl2l","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmeric%2Fl2l/lists"}