All Projects → Russoul → Idris2-Lua

Russoul / Idris2-Lua

Licence: MIT license
Lua backend for Idris 2

Programming Languages

Idris
72 projects
lua
6591 projects
Makefile
30231 projects
c
50402 projects - #5 most used programming language
shell
77523 projects

Projects that are alternatives of or similar to Idris2-Lua

Idris2-Grin
GRIN backend for Idris2
Stars: ✭ 26 (+8.33%)
Mutual labels:  idris2
idris2-pkgs
An unofficial Idris2 package repository for Nix
Stars: ✭ 32 (+33.33%)
Mutual labels:  idris2
idris2dart
The Dart backend for Idris 2.
Stars: ✭ 46 (+91.67%)
Mutual labels:  idris2
idris2-tls
A portable idris2 implementation of TLS
Stars: ✭ 25 (+4.17%)
Mutual labels:  idris2

Lua backend for Idris 2


Tested against Idris 2, version 0.5.1-96c44abb6

Requirements & Installation

All libraries can be installed via luarocks:

luarocks install luautf8 --lua-version=V --local
luarocks install bigint --lua-version=V --local LD='clang -lstdc++'
luarocks install luafilesystem --lua-version=V --local
luarocks install vstruct --lua-version=V --local
luarocks install inspect --lua-version=V --local

Lua 5.1 only:

luarocks install bit32 --lua-version=5.1 --local

where V is your lua version (5.1, 5.2, 5.3).


Before you proceed, fill in the LuaVersion and LuaExe environment variables with a desired Lua version and a name of the executable file for that version.

Build, test and install:

make all && make install

Idris 2 REPL preconfigured with lua codegen will be available under the name idris2-lua located in the same folder as your idris2 executable.

Status

  • The project aims to keep performance reasonable, Lua has many limitations, concerning local variables and nested structures like if-then-else statements, leading to design choices that may decrease performance and limit what the Lua runtime can do to optimize execution. Suggestions are welcome !

  • Major chez tests taken from the official repository under tests/chez run successfully, those which don't are primary FFI or BitXX tests.

Structure and How-Tos

  • Backend needs to know what version of Lua you target as there are incompatibilities:

    Define a global varible LuaVersion with a value: 5.1, 5.2, 5.3

  • If you want to run generated code within the REPL, define LuaExe with the name of the Lua executable (which should be in PATH) of the target version. If the variable is undefined, the backend will default to lua.

Good to know

  • Lua 5.1 and Lua 5.2 do not support 64 bit integers ! Best precision you can get is 52 bits. Also, if you use Buffers maximum precision is 48 bits, disregarding the Lua version ! This is planned to be fixed moving to native buffers.
  • Bits8, Bits16, Bits32, Bits64 are not yet implemented
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].