(Note: We may earn commissions from products/services you click on. This is at no extra cost to you.)
Table of Contents
Initially, Lisp was an Object-oriented programming language. The Common Lisp Object System (CLOS) was added after a while, precisely in the mid-70s. It was added as an abstraction layer over the foundational Lisp concept. However, some people argue that it was added as a new programming paradigm into the initial common lisp variant. Clos was a fourth-generation system, and it was based on earlier object-oriented extensions. But it didn’t include most of the CLOS abstractions.
In 1994, Lisp became the first standardized object-oriented language. The great thing about Lisp is that it doesn’t have modules, routines, objects, variable types, callbacks, and any other complicated codes or the more recent languages. However, it can provide you with all you need to create a powerful code.
Note that original Lisp was highly used in the mid-sixties for object-oriented programming, way before discovering objects as a programming paradigm. Initially, objects were identified as symbols with property lists. And property lists were pairs of keys and values. Moreover, earlier Lisp papers used the idea of classes.
Try something new and interesting. Click this affiliate link to register for the Data Science Masters Program.
What’s CLOS?
The Common Lisp Object System is the provision for object-oriented programming, a part of ANSI Common Lisp. This powerful dynamic object system differs radically from the object-oriented programming facilities common in more static languages like C++ or Java. CLOS gets its inspiration from earlier Lisp object systems like MIT Flavors and CommonLoops. However, CLOS is more general than the two.
As earlier stated, CLOS was proposed as an add-on but later was adopted as part of the ANSI standard for Common Lisp. Since then, CLOS has found its way into other Lisp dialects like EuLisp or Emacs Lisp.
The building blocks of CLOS include classes, instances of those classes, methods, and generic functions. Besides, CLOS offers macros to define these building blocks: defmethod, defclass, and defgeneric. The method make-instance creates the instances.
Each class in CLOS has multiple superclasses, a list of slots, and a special metaclass. It’s possible to put the slots into classes since all instances of a class share a standard slot. Still, you can set the slots into instances.
You can specialize methods upon one or all required arguments in CLOS. That makes CLOS a multiple dispatch system. This is different from most object-oriented programming languages that are single single-dispatch, i.e., method specialization is only on the first arguments.
Another unique feature is that classes don’t provide namespaces for generic methods or functions. Rather, methods are defined separately from classes and lack special access.


What are Object-oriented examples?
Object-Oriented programming, also called OOP, is a programming paradigm relying on the concept of classes and objects. OO programming languages are handy in structuring a software program into smaller, simple, and reusable pieces for a code blueprint – normally called classes. These code blueprints are then used to create objects. This means that you can create objects and reuse them throughout the entire program. More so, you can manipulate the objects to get desired results.
The OOP work on the principle of abstraction, inheritance, encapsulation, and polymorphism:
- Class: this is a group of similar entities – and it is logical components rather than a physical entity. Ideally, it is an abstract blueprint for creating more specific, concrete objects. It can represent broad categories that share attributes.
- Objects: this is an instance of a class; a class can have multiple instances in a program. In languages like Java, the Object contains both the function and the data, and it operates on the data.
Here is an example:
Class: Expensive Cars
Objects:
- BMW
- Toyota
- Mercedes
- AUDI
- Subaru
Attributes/Properties:
- Colour
- Price
- Speed
Methods:
- Reverse
- Braking
- Driving
You can use a class to create car-type objects. Take a look:
Example 1
Class: Expensive Cars
Object: BMW
Attributes/Properties:
- Colour: white
- Price: $60000
- Speed: 320km/h
Methods:
- Reverse ()
- Braking ()
- Driving ()
To become a professional developer, you must get flawless control over the various object-oriented programming concepts.
To create a standout program, you should begin by grouping all related information forming a class. This way, your code will be shorter as well as easier to maintain.
So, you could think to organize your information in an Object-oriented programming language as:
- Create a parent class, i.e., Expensive Cars, as the blueprint of the information and methods that all cars will have, regardless of the types.
- Formulate child classes that represent different subcategories of the Expensive Cars under the generic parent blueprint.
- Create objects from the child class to represent Expensive Cars within that subgroup
- Add the attributes and behaviors/methods to the child classes to show differences.
Note that a Child Class inherits properties from the parent class. To inherit a class, you’ll need to extend. So, in our example above:
The Expensive Car class is a generic template as it contains only the structure about data and behaviors common to all cars.
You can then create child classes of Expensive Car depending on how many you want – ExpensiveCarBMW and ExpensiveCarAUDI. These two inherit the behaviors of Expensive Car (costly) and have their own unique behaviors of cars of that subtype.
Finally, create objects of the ExpensiveCarBMW and ExpensiveCarAUDI type to represent that car.
What is Lisp used for?
Lisp is a very common language with a wide range of applications. Ideally, multiple programs have been built using Lisp. However, the commonest is Artificial Intelligence (AI), machine learning, and other forms of advanced programming that require recursive logic.
The reason why LISP is used in these areas is that:
- Homoiconic code, a feature that allows structured self-modifying code. A homoiconic language has a code that can be easily manipulated as data using the language. Therefore, developers can infer the internal representation of the program by reading the program itself. Normally, languages with this property are termed as code as data. In Lisp, code and data are s-expressions and can be returned, passed, or assigned to variables and have their contents mutated; thus, the code is FirstClass.
- Syntax-aware macros. This mechanism allows the rewriting of boilerplate code. Boilerplate are repeated code sections in multiple places with minimal to no variation. The significant advantage of this is that it reduces the initial time needed to develop software because you’ll be reusing things. Additionally, it reduced complexity giving a cleaner code.
- Pragmatism. The design of Common Lisp allows getting stuff done by working professionals. As a rule, most functional languages lack this feature.
- Flexibility. LISP offers a wide range of ways to deal with a problem. This gives you the flexibility to choose the right method depending on your needs. While some techniques are quick and dirty, others will provide you with a clean code at a reasonable speed.
- Wartiness. The real world can get messy. Pragmatic coding either uses or invents chaotic constructs. However, Common Lisp has enough wartiness that it can get stuff done.
Click this affiliate link to register for Data Science Certification Training.
Lisp is tremendously productive for those who know it well. Lisp was the second and probably will be one of the last programming languages in use. Every decade it re-invents itself to accommodate new programming methods and ideas.
Accomplished developers know that perhaps the best way to use Lisp is as a kit for inventing programming languages that allow writing better programs.
Otherwise, Lisp has excellent applications in Animation and Graphics, Artificial Intelligence, Bioinformatics, Data Mining, B2B and E-Commerce, Electronic Design Automation (EDA), and Semiconductor applications. Still, Finance, Intelligent Agents, Expert Systems, Knowledge Management, and Mechanical Computer-Aided Design (CAD) have extensively utilized Lisp.
Interestingly, Modeling and Simulation, Natural Language, Optimization, Research, Risk Analysis, Scheduling, Telecom, and Web Authoring can be powered by lisp – these are not the only things.
Write a section discussing: “What are object-oriented examples?” Please use this title as the heading. (400 words) – repeated
Object-oriented programming in common Lisp
To implement Object-oriented programming in a common lisp, you need to understand CLOS. Most developers will define OOP as simply defining objects and sending them messages and code attached to the objects to respond to the send messages. A method is basically a code that responds to specific messages. Partly, the power of OOP is its ability to have a standard message.
How does OOP operate in a common lisp?
Standard Lisp Object System (CLOS) is the sole way of performing Object-oriented programming in Common Lisp. CLOS has a rich history as it was one of the many proposed Object-oriented programs tested, implemented, and presented by the LISP community. Keep in mind that it doesn’t have the maturity of flavors OOP or the simplicity of Object Lisp, but CLOS stands out because it is the most general of all choices. The complex part of CLOS is due to deliberate attempts to cover all bases.
The basic elements in CLOS are:
- Classes, created with defclass.
- Instances of classes, defined with make-instance.
- Methods represented with defmethod.
CLOS methods are called like functions instead of having a “send message” command. Actually, they are functions, and defmethod is a defun extension.
Classes and Methods
Methods have a close association with classes. You’ll perform the same things to everything in a particular class. If you wish to treat some things differently, make a new class or subclass.
Click this affiliate link to register for the Data Science Masters Program and become an industry expert.
The process of creating a program using CLOS is similar to other Object-oriented programs. First, define classes (defclass). For instance, if you wish to implement a cooking system, define food classes and methods for preparing the food.
(defclass name (superclasses) (slots)
options)
Second, define the methods – defmethod which comes in the form of:
(defmethod name (specialized-parameters)
expressions)
In the case of a particular variable, it should be a list of the form or a standard variable name.
Slots and instances
Objects clear differ, and instances represent objects of a class. For instance, there are different people on earth, and each one has different names, weights, ages, etc. CLOS lets you capture these details using slots.
The slots in CLOS closely resemble the slots in the MOP frame system. Typically, each slot has a value and a name. So, upon creating an instance, the slots are assigned initial values – later, you can read and modify the values.
The specification of the type of slots within an instance, their initial values, and how you can read and modify them is done when defining a class. Note that CLOS offers a significant amount of control over how the slots behave; so, the process can be a little complex.
Common Lisp object system tutorial
Understanding object-oriented programming in common Lisp can take quite some time. So, it requires many exercises. Nevertheless, let’s elaborate on few things to make things much more manageable.
Defining Classes
You can create the user-defined classes using the defclass macro; thus, establishing a class as a data type. Its syntax appears as:
(defclass class-name (superclass-name*)
(slot-description*)
class-option*))
Slots represent variables storing data or fields, and a slot description comes in the form slot-name slot-option*. Each option is a keyword, and a name, expression, and other options follow it.
Common slot options are:
- :accessor function-name
- :initform expression
- :initarg symbol
For instance, define a Box class with three slots length, width, and height.
(defclass Box ()
(height
width
length))
Write Control to a Slot
Classes are meaningless unless the slots bear values that you can access, read or rewrite. It’s possible to specify accessors for slots when defining classes – for instance:
(defclass Box ()
((height :accessor height)
(width :accessor width)
(length :accessor length)
)
)
Also, you can separate accessor names:
(defclass Box ()
((height :reader get-height :writer set-height)
(width :reader get-width :writer set-width)
(length :reader get-length :writer set-length)
)
)
Creating Instance of a Class
The function (generic) make-instance creates and returns a new class instance. Syntax:
(make-instance class {initarg value}*)
Example
Box class, with three slots, length, width, and height. Create source code file main.lisp and then type the code:
(defclass box ()
((height :accessor box- height)
(width :accessor box-width)
(length :accessor box-length)
)
)
(setf item (make-instance ‘box))
(setf (box-height item) 10)
(setf (box-width item) 10)
(setf (box-length item) 5)
(format t “Height of Box is ~d~%” (box-height item))
(format t “Width of the Box is ~d~%” (box-width item))
(format t “Length of Box is ~d~%” (box-length item))
Executing the code returns:
The height of the Box is 10
The width of the Box is 10
The length of the Box is 5
Defining a Class Method
To define a method within a class, use the defmethod macro. In the example above, you can include a method called volume. So, create a source code file: main.lisp and then type the code:
(defclass box ()
((height :accessor box- height)
(width :accessor box- width)
(length :accessor box- length)
(volume :reader volume)
)
)
; method calculating volume
(defmethod volume ((object box))
(* (box- height object) (box- width object)(box- length object))
)
;setting the values
(setf item (make-instance ‘box))
(setf (box- height item) 10)
(setf (box- width item) 10)
(setf (box- length item) 5)
; displaying values
(format t “Height of Box is ~d~%” (box-height item))
(format t “Width of the Box is ~d~%” (box-width item))
(format t “Length of Box is ~d~%” (box-length item))
(format t “Volume of Box is ~d~%” (volume item))
Executing the code returns:
The height of the Box is 10
The width of the Box is 10
The length of the Box is 5
The volume of the Box is 500
Object-oriented programming languages
Nearly every developer at some point uses objected oriented programming paradigm. Typically, it is the most popular paradigm; thus, it is taught as a standard way of coding in the most educational careers of programmers.
Click this affiliate link to register for Data Science Certification Training.
It’s true; programming is challenging, but it is a crucial way of expressing an idea as a code. The primary challenges that coders face while developing software or an application are miscommunication among team members.
Technical issues might slow the entire process – talk of scaling codes and legacy codes, consistent problems.
Object-Oriented Programming Full Concept
Object-oriented languages allow programmers to work like in real-life entities. Objects can store multiple different methods in the form of data, knowledge, and state. Every Object in object-oriented languages has its own copy of the instance variables, and it operates on the following principles:
- Encapsulation: encapsulation allows developers to quickly and easily understand the code and reuse the code in other application projects.
- Abstraction: principle ensures that your apps can be easily extendible to any platform, making them a key element in software design.
- Polymorphism: A significant property of object-oriented programming that lets programmers write programs that can be easily recreated and reused in other projects
- Inheritance: this principle comes with flexibility, resulting in better organization of code in simple smaller units.
OOP is applicable in any web application for data analysis, accurate coding, less development time, easy testing, debugging, reusability, less data corruption, and maintenance. Besides, it lends transparency and eases to less complex applications.
Object-Oriented Programming Languages Examples
Java
Java is the most demanded object-oriented language for enterprise-grade application development. With Java, every necessary tool is presented to developers in a pretty straightforward way, allowing them to build software solutions and applications quickly.
Java is portable, scalable, and robust. Unlike other languages, you write it once, but you can run anywhere. Thus, building java web systems and applications are straightforward, thanks to the excellent development ecosystem.
Python
Though its codes are not fully OOP, Python supports it. Combining its readability and flexibility and OOP paradigms in creating complex data science operations makes Python an admirable programming language.
According to the Stack Overflow survey, Python is one of the most loved languages due to many factors. Apart from being cross-platform, it has many extensive libraries such as Django, PyTorch, Theano, Scikit-Learn, TensorFlow, Keras, and Pandas.
Other languages include Golang, C++, Ruby
Conclusion
Lisp is an object-oriented language, but it hasn’t adopted the object-oriented model. Instead, the model is one more permutation of the abstractions of the foundation of Lisp. Lisp shows its Object-oriented features via a program written within it called CLOS.
The good thing with Lisp is that you can mold it into various languages. There is a direct mapping between the foundational abstractions of Lisp and the concepts of object-oriented programming. However, CLOS’s size tends to uncertain about this fact.
Much of what is needed from Object-oriented programming is already in Lisp, and with a bit of code, you can surprisingly get the rest. At a minimum, Object-oriented programming should mean Objects have properties, and they respond to messages. Besides, they inherit the properties and methods of their parents.
Lisp offers several ways to store collections of properties, and hash tables are one way of representing tables.
Lisp family features some powerful programming language. This family features an immense amount of meta ability allowing developers to invent their little worlds. Usually, it takes a while to figure out each developer’s little world. For this reason, Lisp is considered a HackerLanguage rather than a commercial language. Some people tend to reason that Lisp isn’t a programming language but rather a meta-language with conventions and libraries, making it closely resemble a programming language.

Luis Gillman
Hi, I Am Luis Gillman CA (SA), ACMA
I am a Chartered Accountant (SA) and CIMA (SA) and author of Due Diligence: A strategic and Financial Approach.
The book was published by Lexis Nexis on 2001. In 2010, I wrote the second edition. Much of this website is derived from these two books.
In addition I have published an article entitled the Link Between Due Diligence and Valautions.
Disclaimer: Whilst every effort has been made to ensure that the information published on this website is accurate, the author and owners of this website take no responsibility for any loss or damage suffered as a result of relience upon the information contained therein. Furthermore the bulk of the information is derived from information in 2018 and use therefore is at your on risk. In addition you should consult professional advice if required.