When I started out with nimterop, I was forced to leverage gorgeEx and create a 
separate binary toast due to this exact limitation. Nimterop uses tree-sitter 
which is a C/C++ parsing library for a variety of programming languages so it 
wasn't possible to load it during compile time.

Initially, I converted the tree-sitter AST into S-expressions which was piped 
in and converted back into a data structure in the VM and then converted into 
Nim. This was slow and clunky so the entire C => Nim processing is now done in 
toast.

I ended up with two advantages - toast is much faster, not by just avoiding the 
double conversion but also because the VM is slower. In addition, toast can now 
be used as a standalone tool if anyone prefers that approach, similar to c2nim.

I would certainly have preferred having the macro system available but at least 
in this particular case, it worked out positively.

I do agree though that having the full stdlib and FFI available during CT will 
be helpful for some cases but the performance implications might be worth 
consideration.

Reply via email to