Hacker News new | past | comments | ask | show | jobs | submit login
Cmacro: Lisp Macros for C (github.com/eudoxia0)
67 points by thesephist on July 30, 2022 | hide | past | favorite | 10 comments



That's me! I was really naive about parsing back then and the "parser" is really not stellar.



I think this is doing something more sophisticated since it seems to understand C syntax. I don’t think it’s hygienic though which is a shame.


hygienic macros are a fun intellectual curiosity but using regular macros with gensym as needed is more practical


Oh man I couldn't disagree more. Having used Nim's hygienic templates, I strongly believe the escape hatch should be the other way round. Hygienic by default, tag individual identifiers as being 'dirty' to inject them as is into the surrounding scope.

Edit: actually, I realize I don't know whether you meant 'macro' in the C sense or the Lisp sense. I was thinking C


When people say "Lisp macros" they usually mean Common Lisp defmacro-flavored ones. Any problems introduced by lack of hygiene can be papered over with separate variable and function namespaces and gensyms.


Not really because a huge feature of hygiene is accurate symbol provenance for syntax error reporting. syntax-case (syntax-parse for Racket) lets you do anything a Common Lisp like macro system can do but is still hygienic by default.


The example using qsort illustrate how good was the lambda proposal for c23 that was rejected.


Lambdas can still be written using GCC extensions. https://github.com/FrozenVoid/C-headers/blob/main/lambda.h


Wow, returning a local function from a ({...}) block is sick. I like that.




Consider applying for YC's W25 batch! Applications are open till Nov 12.

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

Search: