O'Reilly logo

Land of Lisp by Conrad Barski M.D.

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Common Lisp Structures

A structure is an advanced datatype available in Common Lisp. Structures and their properties can be a useful way to represent data in your code.

Working with Structures

Structures can be used to represent objects with properties, as you might find in a typical object-oriented programming (OOP) language using the defstruct command, like so:

> (defstruct person
             name
             age
             waist-size
             favorite-color)
PERSON

According to the definition in this structure, a person has four properties (also called slots by Lispers): name, age, waist-size, and favorite-color.

Having defined this structure, we can create instances of a person using the make-person command, a special function that defstruct has automatically created for us:

> (defparameter ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required