Git Product home page Git Product logo

idris2-lua's Introduction

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.