3 ms·
> The former is nicer to program while the latter is nicer to use. When I have such a situation, I'm inclined to write myself my own pre-processor (as I did fo
by jll29 2y ago
> The former is nicer to program while the latter is nicer to use.
When I have such a situation, I'm inclined to write myself my own pre-processor (as I did for Pascal once in a previous millenium, on an Atari ST 520+), so that you can write in a style that is nicer to program in, which gets pre-compiled into something that is nicer to use from your client code.
Nothing comes without downsides: the price of this is that other developers need to understand your idiosyncratic pre-processor, so this method works best for "single author" code/personal projects.
What you don't want in a team is each coder having their own way of doing things, so that you cannot share libraries and helper functions.
BTW, the best book on the OP's topic of production coding in C and implementing type-safe ADTs is Chris Hanson's book "C: Interfaces and Implementations." It contains some eye-opening tricks even for experienced developers in (standard) C.
- RossBencina 2y agoI wonder are there any existing metaprogramming frameworks for C? (something like C#'s Roslyn) I've been playing around with ANTLR and Python but curious to know what I've missed.
- hgs3 2y agoIt's worth mentioning that there are dedicated processors, like m4, and templating engines, like Jinja, if you need something battle-tested.