Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I think the title might be misleading here. It doesn't really transpile Common Lisp to C, it requires you to write in a C-like Lisp dialect so it gets translated to C. Might as well have been an entire Lisp dialect with a compiler of its own.


I think the idea is that you write C-with-sexpr-syntax, but by embedding those s-expressions in Common Lisp, you can make use of macros written in Lisp to generate C code. Essentially, it's a saner preprocessor for C that requires you to write in funky syntax.

I think this would be even more interesting if it could do the C -> s-expression transformation, so that code already written in C could integrate calls to Lisp macros without needing a full rewrite.


A C->S-expression compiler would have to produce very obvious and simple mappings in order for a macro system to be usable. Another way of saying this is that a simple and standard AST would be nice.


The Vacietis (https://github.com/vsedach/Vacietis/) reader can be easily adapted to do that. You can see examples in the unit tests:

https://github.com/vsedach/Vacietis/blob/master/test/reader-...

As-is, C block constructs get mapped directly to Common Lisp special forms like tagbody and prog because those implement a superset of C control flow semantics. Pick different names in vacietis.c and you have an AST.


I don't know what the title was when you commented, but what I see is "Compiler using Lisp’s macro system for metaprogramming C-like languages". That doesn't imply transpiling from Common Lisp (though it does impli transpiling), and it seems like a very pithy description of what C-Mera actually does (which is also what you said in your first sentence).

The nice thing about this is that you get the full power of Lisp macros, which is where the metaprogramming comes in, but it still resembles C well enough.

Of course, the Lisp compiler can't actually do C type checking in this system, so you still need to map C compiler errors and warnings back to the source -- that may well turn out to be a pain (and almost certainly does).

EDIT: I'm curious: why the downvote?




Consider applying for YC's Fall 2025 batch! Applications are open till Aug 4

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

Search: