Next: , Previous: , Up: Making a small Lisp project with quickproject and Quicklisp   [Contents][Index]


5.10.1.3 Write some code

  1. open $HOME/src/lisp/swatchblade/swatchblade.lisp and start hacking.

    I define variables with defvar and defparameter, functions with defun and defgeneric, macros with defmacro, classes with defclass, etc.

    As I write each one, I compile it immediately with ‘C-c C-c’ and occasionally switch over to the REPL to run some code.

  2. As I use symbols from other projects, I update the defpackage form in package.lisp to import symbols. For example, I might want to use several Vecto symbols without package prefixes, so I could do this:
    (defpackage #:swatchblade
      (:use #:cl)
      (:shadowing-import-from #:vecto
                              #:with-canvas
                              #:rounded-rectangle
                              #:set-rgb-fill
                              #:save-png-stream))
    
  3. I don’t put any library management code directly into Lisp source files. If I decide to use more external projects, I edit swatchblade.asd and add to the :depends-on list,
    (asdf:defsystem #:swatchblade
      :serial t
      :depends-on (#:vecto
                   #:hunchentoot
                   #:cl-colors)
      :components ((:file "package")
                   (:file "swatchblade")))
    

    Reloading the system with ql:quickload will install (if necessary) and load any newly-required systems.