Looking for a Lua alternative
Julian Fondren
julian.fondren at gmail.com
Thu Dec 14 20:34:20 UTC 2023
On Thursday, 14 December 2023 at 08:38:02 UTC, solidstate1991
wrote:
> After losing a battle with trying to get Lua 5.4 working on my
> own end, with problems I previously solved kept reappearing,
> and other problems just were unable to fix for no good reason,
> I've decided to drop it from my own game engine in favor of
> some replacement.
What problems did you have with Lua 5.4? Building it, linking it,
driving it from D, Lua as a language? It's very tough
competition. I got to 'hello world' pretty quickly with
bindbc-lua,
```d
#! /usr/bin/env dub
/++ dub.sdl:
dependency "bindbc-lua" version="~>0.6.0"
versions "LUA_54"
libs "lua-5.4"
+/
import bindbc.lua;
import std.stdio : writeln;
void main() {
LuaSupport ret = loadLua();
assert(ret != luaSupport.noLibrary, "Lua shared library
failed to load");
assert(ret != luaSupport.badLibrary, "One or more symbols
failed to load. Bad version?");
assert(ret == luaSupport);
auto L = luaL_newstate();
assert(L, "failed to open Lua");
luaL_openlibs(L);
luaL_loadstring(L, "print 'hello world'");
lua_call(L, 0, 0);
lua_close(L);
}
```
and Lua 5.4 has integers:
```
$ lua -e 'print(_VERSION, 9223372036854775807)'
Lua 5.4 9223372036854775807
vs.
$ luajit -e 'print(_VERSION, 9223372036854775807)'
Lua 5.1 9.2233720368548e+18
```
More information about the Digitalmars-d
mailing list