RSS Feed

Lisp Project of the Day


You can support this project by donating at:

Donate using PatreonDonate using Liberapay


Tests 🥺
CI 🥺

In post number 50 I've reviewed the literate-lisp system which allows to write you lisp code in org-mode files and to load them as usual lisp files.

Papyrus does a similar trick but for Markdown files. It adds a named readtable to load markdown files as usual lisp code.

The library itself is less than 20 lines of code!

Here is how does the hello world look like using a literate programming style and Papyrus:

(defpackage #:hello-world
      (:use :cl :named-readtables))
    (in-package #:hello-world)
    (in-readtable :papyrus)

# Hello world with Papyrus

As you probably know, every programmer starts his learning of the
new programming language from the "hello world" program.

Simplest hello world program outputs a text "Hello World!" in console and exit.

Here is how we can output this program in Common Lisp:

(defun main ()
    (princ "Hello World!")

Now we can load it and run our main function:

POFTHEDAY> (ql:quickload :papyrus)

POFTHEDAY> (load "docs/media/0139/")

POFTHEDAY> (hello-world::main)
Hello World!

Also, you can add markdown files as ASDF system's dependencies!

However, there are view drawbacks because of Markdown's limitations and Papyrus simplicity:

  • All files have to start with an indented block of code to set proper read-table.
  • Emacs does not understand the current package when you are doing C-c C-c.
  • It is impossible to define blocks of lisp code which shouldn't be evaluated.

But literate-lisp system addresses all these issues.

Brought to you by 40Ants under Creative Commons License