Laurent Senta had the opportunity to go to the 5th European Lisp Symposium to present Climb, the project I've been working on during the past 2 years. He did an excellent job at writing a 4-page paper that sums up the interesting parts of the project (Download).
I recommend reading the short article before getting to the slides. Download the PPTX if you want to see the speaker text.
Climb - Property-based dispatch in functional languages
Abstract: "Climb is a generic image processing library. A generic algorithm interface often requires several different specialized implementations. Olena, a C++ library, solves this using properties.
We present a way to dispatch a function call to the best specialized implementation using properties in a dynamic programming language: Common Lisp. Then, we introduce examples of algorithms and properties used in image processing."
In Lisp, there is not such thing as a dot notation to call an object method. Methods are functions taking the object as first argument. To mimic the dot operator that allows chaining we would like to write:
($ (image "in.png"); Note: . is not a valid name, we use $ instead(resize 200100)(erode)(save "out.jpg"))
Hopefully, Lisp allows to rewrite the previous snippet into code that actually works with macros.
With temporary variables
The first way to rewrite it is with a serie of assignement. It uses a temporary variable that is being passed along. progn is being used to group the actions into a single block that returns the tmp value.
gensym creates a local variable with a unique name
car is the first element of the list, cdr is the rest
The previous way was probably how would have written it in your code. Since we are programmaticaly rewriting the operation, we do not care about how readable the output is. We can remove the use of the temporary variable inlining the calls.