Common Lisp/First steps/Features

From Wikibooks, open books for an open world
Jump to navigation Jump to search
  • Common Lisp is a high-level programming language with automatic storage management (aka garbage collection).
  • Common Lisp is a multi-paradigm language. It allows you to write programs in the procedural/imperative, functional/applicative and object-oriented styles. These styles may be freely mixed in a Common Lisp program. This allows you to choose the approach and paradigm according to your application domain.
  • Common Lisp is written in a fully-parenthesized, prefix notation. This means that applying the function func to arguments x and "hello" is written (func x "hello") rather than the more conventional func(x, "hello"). This might make the syntax harder to learn if you are accustomed to other languages, but after some practice it becomes quite natural. It also makes macros possible.
  • Macros allow you to extend the Lisp syntax. They can be used to define new keywords. Common Lisp macros are much more powerful than (for example) C macros: Lisp macros are code generating programs in their own right.
  • Common Lisp has an interactive top-level. Most implementations allow you to type in programs at a prompt as well as loading them from a file, allowing explorative programming. The prompt can also be used for interactive debugging.
  • Common Lisp allows incremental compilation. Most implementations have a compiler (either native-code or bytecode) as well as an interactive top-level. Compiled and interpreted code may be freely mixed.
  • Common Lisp can provide high performance (but this is highly dependent on the implementation). Some implementations can compete with C/C++ compilers.