5
lorentz
2y

How many layers of increasingly verbose macros generating calls to each other is acceptable in Rust? I have to choose between 2 and 3 but IMO the 3 macro setup is nicer because it allows shit like walking a list, windowing the items and skipping the last to be separated from the actual things that are being generated.

Comments
  • 2
    I need to turn an N-ary function into a fully curried set of structs that all implement Any, and take and produce Box<dyn Any>
  • 0
    It honestly doesn't matter. Macros are mostly a binary affair: either they work or they don't. Debugging macros is pretty scuffed either way whether it's nested 2 levels or 3
  • 0
    Although in your case I would probably eat the compile time cost and just use a proc macro. Much simpler :D
  • 0
    @12bitfloat In the end I just needed three rules in the controller macro and they each call a distinct variant of the writer macro once. I don't want to inline it because the controller macro generates names via the paste crate and I like that currently the occurrences of each name are very easy to follow since they get bound to a single token in the writer's argument list.
Add Comment