Thoughts on creating objects in Lisp

If you work with classes in Lisp, you might want to hide the details of creating an object of a class. This practise is generally known as the factory method pattern. I’ll show a very simple example. Let’s assume, you have defined the following […]

Defining Lisp classes in packages

In Lisp, when you define classes in packages, you have to remember that you have to explicitly export the accessors too. For example, you define the following package with a class inside. (defpackage :mhn-foo   (:use :common-lisp)   (:export #:fooclass)) (in-package :mhn-foo) (defclass fooclass […]

Making decisions

It is interesting to have a look at how you make decisions in different programming languages. In Python, for example, the code is straightforward. >>> if 1 < 2: …     print ‘smaller’ … else: …     print ‘bigger’ …  smaller >>>  […]

Serializing Lisp lists

In Lisp, it is very easy to serialize and deserialize lists into files. You can use the macros with-open-file and print for this. Using macro with-open-file makes sure that the file is closed automatically even in case of failures. The print macro prints lists […]

JSON in Python and Common Lisp

Both, Python and Common Lisp have libraries for writing and reading JSON format. JSON can be used as an alternative to XML, when not only machines will read the data. XML can be hard to read when you have more tags than data. JSON […]

Regular Expressions in Lisp

There are various different regular expression libraries available for Lisp. A nice overview can be found at CLiki. I had a look at the Portable Perl-compatible regular expressions for Common Lisp (CL-PPCRE). Installation is very easy using Quicklisp. After installation you can add the library […]

Package basics

Packages form the basic building blocks of software components in many programming languages. For example, in Java you use the package statement to define the package for a class as follows. package a.b; public class C {     public static void main(String[] args) […]

Unit testing in Lisp

There are some frameworks and libraries available for doing unit tests in Common Lisp. You’ll find a list for example in Wikipedia. I have decided to have a look at lisp-unit from Chris Riesbeck, Associate Professor in the Department of Electrical Engineering and Computer […]

Some notes on lists in Lisp

As you have seen in my previous post, working with lists is easy if lists are build into a programming language. But what if the language itself is made of lists? The Lisp programming language is made of lists. Let’s have a look at […]