The characteristics of Lisp (I had to write a new article if I couldn't publish a comment)

Source: Internet
Author: User

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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.