Old Habits

I’m enjoying Planet Lisp’s feed of new Lisp projects at github: http://planet.lisp.org/github.atom.

Long long time ago I fell into a coding convention.  Most of my little projects have a file where I define the package (or packages); and this file is loaded first.  Most projects I see at github follow this style.  But a few don’t.  Further I never ever switch packages inside of a given source file.

I think it’s time to set aside these habits.

I’m reasonably confident that both these habits arose because of Emacs limitations.  Back in the day it wasn’t particularly clever about handling the package.   I don’t think I ever worked in a version that was so limited that it required the package to be asserted in the mode line, but I certainly have worked on code bases were every file asserted the package twice, at the top, once in the mode line and once via in-package.

I certainly worked in variants of emacs that had firm limits on the in-package form; i.e. that it appear early in the file, and that you not switch packages.

The only reason this worth stating out loud is because I see a lot of little projects that consist of three files:   my-project.asd, package.lisp, and my-project.lisp.   That pattern is, I think, obsolete.  There really isn’t a good reason anymore for the package.lisp file for simple little things.

  (in-package #:cl-user)
  (defpackage #:my-little-package
    (:uses #:common-lisp))
  (in-package #:my-little-package)

  (defun my-awesome-hack ()
    ; ...
  )

While I am waffling about the value of including a mode line at this point, as shown I’m leaning toward eliminating it too.

WDYT?

Leave a Reply

Your email address will not be published. Required fields are marked *