On Tue, Jul 04, 2017 at 01:52:41PM -0700, spearman wrote: > I have built up a good toolchain for C programming including static analysis > and runtime testing tools, but I find the C preprocessor is really lacking > for metaprogramming facilities. > > Here is an implementation of "Lisp" macros for C: > https://github.com/eudoxia0/cmacro > > It doesn't seem to be actively maintained and a bit buggy (weird formatting > errors), and, well, it's Common Lisp :\ > > I made a start on converting the above into Racket: > > https://github.com/spearman/rcmacro > > At this point it is little more than a main module with command-line options > and stubs for the rest of the implementation. > > Two sticking points so far are error handling and finding a replacement for > the "packrat parser" (esrap) that cmacro relies on, as highlighted here: > https://github.com/eudoxia0/cmacro/blob/master/src/parser.lisp#L290 > > If there is something available for Racket along the same lines as esrap, > which uses TDPL grammar, I may be able to move forward with adapting this > code, otherwise it might be a lost cause and better off just coming up with > something from scratch (and I might learn something in the process). However > it seems like a large task and I would be essentially starting from first > principles. > > Before I make a choice on whether to proceed, I wanted check first if there > are already any Racket-based (or Scheme-based!) implementations of macros for > C. > There is this Racket implementation for C++: > > https://github.com/elfprince13/RacketMacros4Cxx > > but it requires a custom llvm/clang build, and the "demos" don't look very > much like what I had in mind.
Not exactly what you're asking for, but Gambit is a Scheme implementation that compiles to C (or C++). You can define functions and specify what C ode should be used to implement them. So in a sense, mcros in Gambit end up generating C code. -- hendrik -- You received this message because you are subscribed to the Google Groups "Racket Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.