(defgeneric do-something (object))
(defmethod do-something ((object foo))
(something every foo can do))
;; bar is the same as foo
(defmethod do-something ((object baz))
(something only bazzes should do))
Templates and concepts are certainly a powerful tool, and I personally like them (as I've come back to C++ after a long break). But macros let you do something else entirely. You can create entirely new syntactic structures, or modify existing functions (see Norvig's PAIP, chapter 9, where macros are used to memoize recursive functions), or any number of other things.I think I said as much in my comment.
> This seems more akin to Common Lisp's defgeneric and defmethod
Except that Templates are statically dispatched and type-checked.
But also one can perform meaningful compile-time computation with them - I have used this in anger to implement stencils and iteration logic for partial differential equation solvers in 1-3 dimensions so I can say from experience that it is not a mere curiosity. And I don't think that CLOS really has any analog for the techniques used to implement std::tuple.
> But macros let you do something else entirely. You can create entirely new syntactic structures, or modify existing functions (see Norvig's PAIP, chapter 9, where macros are used to memoize recursive functions), or any number of other things.
I think the thrust of my comment is that Lisp programmers identify this type-blind AST-mapping functionality as the core of "a Macro System," while users of other languages (with more syntax to begin with) see this as somewhat secondary to the goal of type-checked compile-time computation.
These are going to be controversial assertions in a Lisp thread, but I believe
1. C++ Templates + Concepts is a good Macro facility
2. Most of what makes it good is not borrowed from Common Lisp
On the other hand, I agree strongly with this assertion:
> Scripting languages gain much of their leverage from nested hash tables.