This is a powerful feature for lisp.
The comment in this article cannot be submitted on the csdn blog, so we have to send a new article:
At present, I don't know exactly what the advantages of C ++ macros (in fact, they are also the same during the compilation period) are. (Forgive me for learning lisp for a few days)
====
The difference between macro in LISP and macro in C ++: (Forgive me for N years that I have never used C ++) The LISP Language itself is a s expression, and the list of macro direct operations in LISP, all lisp syntax tools can be used to convert the input list to the target program list.
In comparison, Macro of C ++ only replaces macro. In terms of expression ability.
The Macro of Lisp can implement inert computing and its own syntax structure. The parameters passed to macro can control the number of computations (0 or multiple times) by themselves ), in this way, you can implement the IF, loop, and other Syntax structures by yourself.
====
LISP is not the same as Haskell. Haskell is from Miranda and uses the type derivation in ml for reference. Python's list comperhension is from Haskell. In Cl, a similar incf-Cl library can be used to implement list comperhension. This is the power of Lisp. It has no syntax at all. The code tree is written, and macro is a code generator. Therefore, new language features can be quickly absorbed by lisp.
List comprehension implemented through the incf-Cl library in Common LISP:
CL-USER (15): (LC (* X) (<-X (take 10 (range 0 1/3 5 )))) <br/> (0 1/9 4/9 1 16/9 25/9 4 49/9 64/9 9)
In fact, the next important loop, Oo, and exception handling were all implemented through macro in lisp.
Therefore, Shenma is a float cloud. If you are not satisfied with lisp, you can write a C ++, Java pre-processing extension, and implement various features on your own. Only this capability is built in by lisp, this shortens the distance between evolutionary languages and normal development. Everyone can become a speaker of language.