Hacker News new | ask | show | jobs
by choeger 2716 days ago
Oh my. If only C++ would have used proper macros from the start...
2 comments

I discussed this once with Stroustrup. He mourned that the word "macro" had been "polluted" (his word, though I completely agreed) by the preprocessor and said "templates was the best we could do within the constraints of C".

This was in the mid 90s and things are a lot better these days but still, I had better macro support writing Lisp in the 1970s.

I am ready to believe that hygienic macros would have been difficult, but just using lisp macros should have been straightforward. Tbh, I think that templates were an adhoc, amateurish design decision.
A lot of the arcanity in templates is the arcane C syntax they are shackled to. I wouldn’t call it ad HPC.

Lisp is so much easier. But current C++ is surprisingly expressive and generates pretty good production code. Instrumenting your Lisp with a lot of type declaration is pretty messy too.

There is nothing as "a proper macro". There is proper meta-programming support or a badly design language.
A macro is a metal-level abstraction. So proper macros require proper metaprogramming support. And, I would argue, the other way around.
And I would argue that a Macro is external language put on top of your language as a patch (hack), when your language is not expressive enough for genericity.

Then yes, there is nothing as "proper" Macro. There is just an attempt to fix a limited language in the first place.

And it is something that C++ arrived to solve ( not that badly ) currently.