An Object in Lisp. Part 4

  • What does it mean to be an object?

  • A [computer] language mechanism for binding data with methods that operate on that data. Object (Computer Science).

    • Binding is the creation of a simple reference to something that is larger and more complicated and used frequently. Binding (Computer Science).

    • Data refers to a collection of facts usually collected as the result of […] processes within a computer system […]. Data.

    • […] a method usually consists of a sequence of statements to perform an action, a set of input parameters to customize those actions, and possibly an output value (called return value) of some kind. Methods (Computer Science).

So the following code by the above definitions must be an object.

(defun make-counter-obj ()
  (let ((counter 0))
    (list :increment-counter
          (lambda ()
            (incf counter))
          (lambda ()

(defun increment-counter (obj)
  (funcall (getf obj :increment-counter)))

(defun get-counter (obj)
  (funcall (getf obj :get-counter))
  • ‘make-counter-obj’ creates the binding.
  • The ‘counter variable in ‘make-counter-obj’ is the storage for our data.
  • The two functions/methods ‘increment-counter’ and ‘get-counter’ are definitely methods of some kind, that allow us to operate on the ‘counter data.

Throughout this entire series it seemed to be inevitable that p-lists were to be used not only the actual storage mechanisms for the methods that act on the data, but also in the macros, p-lists are a major data structure.

Right now, I’m pretty comfortable with the implementation of this type of object. But already I can see future implementations. There is definitely another abstraction that can be pulled out of this. The ‘get-object-id’ function is a place to start. All object instances, that use my objects language, use this function. It could be considered part of a parent property.

Right now I want to start integrating Event Driven Architecture to further my cargo-cultism of Lisp.

Have a Happy Holiday,

Joe G


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: