Archive for the 'LISP' Category

Commenting Your Code

In Practical Common Lisp Peter Seibel writes a little about proper form. He mentions comments and I like his style. In Lisp, he says, you denote a comment with a semi-colon (;). You start a
comment with one to four of these, so that some sense of scope is available.

You start a line with four semi-colons if it applies to the whole file.
;;;; This file contains all the functions for ...

Use three semi-colons to comment large sections of code.
;;; Here are the functions for searching and sorting ...

Two semi-colons comment on the code that immediately follows.
;; Ensure that digits are padded with 0s.

And one semi-colon applies to just that line.
; Statistics, number of changed items

I think that’s pretty slick and I think it can (and should) be applied anywhere, regardless of the language. I’m going to make an effort to start using this in my PHP and LotusScript.

My First Lisp

I have only now managed to get through the second chapter of Practical Common Lisp. I am compiling my own Emacs cheatsheet. Here’s my first Lisp program.

(defun hello-world ()
  (format t "Hello, world!"))