4 ms·
I perked up at "like D but with built in sum types". is C interop intended to be as good as D's?
by zem 3y ago
I perked up at "like D but with built in sum types". is C interop intended to be as good as D's?
- FeepingCreature 3y agoIt runs on plain C ABI, so you can just define C functions as `extern(C)`, just as you would in D. But you can also use `std.macro.cimport` to import C headers directly. Check out the Dragon demo, https://github.com/Neat-Lang/neat/blob/master/demos/dragon.nt https://github.com/Neat-Lang/neat/blob/master/demos/dragon.n... : macro import std.macro.cimport; import c_header("raylib.h"); And then you can just use (most of) the Raylib functions and types. cimport is a massive hack: it runs gcc on the header in preprocessor expansion mode, then parses the result. Its tactic for C syntax it doesn't understand is "just skip it and hope for the best." :) Works surprisingly well. On x86, there was a lot to be gained from having a language specific ABI, because the cdecl ABI was so slow. But the x86-64 ABI, much as I may dislike its complexity, is genuinely plenty fast already.