Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
How to generate Lua boilerplate with D (tuxen.de)
73 points by qznc on May 12, 2017 | hide | past | favorite | 5 comments


If you haven't seen this, the D Gems section of the D Tour highlights some of D's most exciting features:

https://tour.dlang.org/tour/en/gems/uniform-function-call-sy...

In particular, here is another explanation of the scope feature presented in the LuaD article:

https://tour.dlang.org/tour/en/gems/scope-guards


Is there something like

    extern "C" { void foo(); }
For D? That way you'd be able to use the LuaJIT ffi. That, in combination with what's in the OP, would be killer.


Yes [0].

    extern (C++) int foo(int i, int j, int k);
In fact, D can both access C++, and C++ can access D, as you can see further down that link, on classes.

But, if you don't want C++, then [1]:

    extern (C) int foo(int i, int j, int k);
Which is actually in the article.

[0] http://dlang.org/spec/cpp_interface.html

[1] http://dlang.org/spec/interfaceToC.html


Yep, except you'd write it

    extern(C) { void foo(); }
https://dlang.org/spec/interfaceToC.html





Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: