-
Notifications
You must be signed in to change notification settings - Fork 1
/
2022-10-10-localua-pallene.dj
22 lines (17 loc) · 1.67 KB
/
2022-10-10-localua-pallene.dj
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
```=lua-meta
title = "Pallene support in localua"
published = "2022-10-10 17:50:00"
description = "localua now supports Pallene."
```
Today I attended Lua Workshop, and Roberto Ierusalimschy's keynote was about [Pallene](https://github.com/pallene-lang/pallene), a language designed as a system counterpart to Lua in a scripting architecture. The language is a typed subset of Lua and can be used to replace C or as an interface between Lua and C. It is still a work in progress, there is no stable release yet.
Pallene works by accessing the internals of the Lua VM, so it requires [a patched version of Lua](https://github.com/pallene-lang/lua-internals). I wanted to try it so I added support for it to [localua](https://loadk.com). You can just use "pallene" instead of the Lua version and it will pull the latest sources of Pallene and its Lua fork and install them in a self-contained directory.
The Pallene compiler does not have an easy way to specify a local Lua directory and I decided against hacking it so you will have to pass `CFLAGS` as an environment variable for it to work.
I have just pushed a localua version that supports this so you too can try Pallene now. Be aware that I have only tested this on Linux, and that it is an undocumented feature which means I do not guarantee I will support it forever. That being said, this works now:
```shell
curl "https://loadk.com/localua.sh" -O
chmod +x localua.sh
./localua.sh .lua pallene
curl -O "https://raw.githubusercontent.com/pallene-lang/pallene/master/examples/fibonacci/fibonacci.pln"
CFLAGS="-I $(pwd)/.lua/include -O2" ./.lua/bin/pallenec fibonacci.pln
./.lua/bin/lua -e 'print((require "fibonacci").fibonacci(10)[8])' # prints 13
```