Converting Lua source to D

AB a at b.c
Thu Mar 5 16:54:35 UTC 2020


On Thursday, 5 March 2020 at 07:44:21 UTC, Jesse Phillips wrote:
> I am making an attempt convert Lua to D. This is less about the 
> conversion and more about exploring the tooling to make it 
> happen.
>
> I have chosen to do this file by file and attempting to start 
> with linint. I wanted to make use of dpp, however I hit a 
> segmentation fault and reduced dependency.
>
> https://github.com/JesseKPhillips/lua/blob/dpp/init/linit.d
>
> I wasn't able to get a core dump for debugging. Anyone willing 
> to give some advice or solution? I have gone through a number 
> of compilers and better.
>
> I have implemented a build pipeline but didn't incorporate the 
> D portion at this time.

I am only guessing, but I think the problem is line 87.
Arrays and slices in D contain a length field and thus do not 
need to be null terminated.
The foreach at line 96 iterates on all valid indices and thus in 
the last iteration you call luaL_requiref(L, null, null, 1).

Try changing

static const luaL_Reg[] loadedlibs = [
   ...
   {LUA_DBLIBNAME, &luaopen_debug},
   {null, null}
];

to

static const luaL_Reg[] loadedlibs = [
   ...
   {LUA_DBLIBNAME, &luaopen_debug}
];



More information about the Digitalmars-d-learn mailing list