Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Common Lisp package definition

In Common Lisp package definition, what is the difference between

(defpackage #:foo
    (:use :cl)
    (:export #:bar
        #:baz))

(in-package #:foo)

and

(defpackage :foo
    (:use :cl)
    (:export :bar
       :baz))

(in-package :foo)

I mean. When I have to use the "#" character? All these symbols are uninternerd, right?

like image 416
csgui Avatar asked Nov 08 '11 12:11

csgui


1 Answers

:foo is the syntax for a keyword symbol, and #:foo is the syntax for an uninterned symbol. When a symbol is used primarily to get at the string that is its name (as in defpackage and in-package), I prefer to use uninterned symbols.

Here are the other options:

  • use a keyword symbol; I don't like how this interns keyword symbols that show up in apropos and other places
  • use a string; I don't like how this gratuitously breaks Allegro's "modern" mode
  • use a plain symbol; I don't like how this both interns a symbol, and how it interns it in a potentially random package

Which style you or anyone else uses is a matter of taste.

like image 200
Xach Avatar answered Nov 16 '22 02:11

Xach