Lisp Macros by Example
It should be noted that the first example can be implemented in C as well:<p><pre><code>    static inline void *null_throws_helper(void *p, const char *msg) {
      if (!p) {
        fputs(&quot;uh oh: &quot;, stderr);
        fputs(msg, stderr);
        fflush(stderr);
        abort();
      }
      return p;
    }
    #define nullthrows(arg) null_throws_helper((arg), #arg)
</code></pre>
In C with the GNU statement expression extension, the above can be more concisely written:<p><pre><code>    #define nullthrows(arg)                                                        \
      ({                                                                           \
        void *p = (arg);                                                           \
        if (!p) {                                                                  \
          fputs(&quot;uh oh: &quot;, stderr);                                                \
          fputs(#arg, stderr);                                                     \
          fflush(stderr);                                                          \
          abort();                                                                 \
        }                                                                          \
        p;                                                                         \
      })
    
</code></pre>
With C++, you can do better by preserving the original type of pointer, or throw an actual exception rather than terminating the program.<p>The C&#x2F;C++ preprocessor macro system isn&#x27;t great, but it&#x27;s good enough to be really useful. For great design, I&#x27;d lean towards the hygienic syntax-rules system used by Scheme.