I want to write C in s-expressions and use compile-time macros. Does anybody know of anything that does this? It should translate the s-expressions into standard C.
+1
A:
How do you mean? Something along the lines of:
(c-expression (int main ((int argc) ((array (pointer char)) argv) (block (printf "%d arguments\n" argc) (if (argc >= 1) (printf "The first arg is %s\n" (ref argv 1))) (return 0)))) => "int main (int argc, char *argv[]) { printf("%d arguments\n", argc); if (argc >= 1) printf(The first arg is %s\n", argv[1]); return 0; }
If so, yes, it's definitely doable. However, it's not entirely trivial.
Vatine
2010-01-14 15:00:51
Sort of like that. Although I don't think the s-expression version would look quite like some of the things you did there.
Ollie Saunders
2010-01-14 16:27:16