kiselgra / c-mera

Next-level syntax for C-like languages :)
Other
405 stars 17 forks source link

Preprocessor directives #59

Closed kiselgra closed 7 years ago

kiselgra commented 7 years ago

I usually write something similar to (comment "pragma omp parallel for" :prefix "#"), but I think having a wrapper for this might make for more readable code. My suggestion:

(defmacro cpp (&rest args)
  `(comment ,(format nil "~{~a~^ ~}" args) :prefix "#"))
(defmacro pragma (&rest args)
  `(cpp "pragma" ,@args))

Not sure if we should have properly scoped #if or not, would be cleaner, but might also miss the point. But then, advanced pre-processing is what we usually do c-mera-side, so this argument is, imo, not as strong against scoping...