Lisp ðŸ‘―

Lisp (historically LISP; from List Processing) was a programming language created in 1958 by John McCarthy. Many dialects have been created over time, and today Lisp is a generic name to refer to all these cousin programming languages.

The most known Lisp dialects today (IMHO) are Clojure, Common Lisp, and Scheme.

Lisp might be mostly known for its heavy usage of parenthesis to enclose its S-expressions (parenthesis-enclosed hierarchical structures used to represent complex data structures as well as program statements itself).

Vocabulary and WTFs

  • datum: a single piece of data (eg.: a string, a number, etc; it's not a strict Lisp term, though it's frequently seem in many Lisp-related texts)
  • atom: unique immutable values – either a number or a symbol, that can also be used both as variable names or as data itself
  • symbol: is a name that's associated to a value or a function. In Lisp, a symbol is what a variable is in C-like languages
  • S-expression: is a syntax for for denoting nested, tree-structured code and data. S-expressions are nestable lists made of atoms and/or other S-expressions (aka.: symbolic expression, sexpr, or sexp; see: S-expression)
  • cons cell: a two-item tuple that's used to implement lists in Lisp. Items are historically named CAR and CDR (reads coulder), being CAR the one holding the actual value of the const cell, and CDR holding a reference to the next item in the list (when CDR is nil the list has reached its end; it's indeed a linked list, and cons cells are how they call its nodes)

Syntax and data types

; Comment lines start with a semicolon
; A list of numbers
(1 2 3 4 5)

Lisp syntax comprises of two things: atoms and S-expressions.

; Comment lines start with a semicolon
; Atoms
; Symbols
; S-expressions

; S-expressions are wrapped in parenthesis-delimited. They are nestable - which means an
; S-expression can be made of additional, inner S-expressions.

; An S-expression that adds two numbers would look like that:
(+ 1 2) ; => 3