In Common Lisp package definition, what is the difference between
(defpackage #:foo (:use :cl) (:export #:bar #:baz)) (in-package #:foo)
(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?
preguntado el 08 de noviembre de 11 a las 12:11
: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
in-package), I prefer to use uninterned symbols.
Aquí están las otras opciones:
- 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 tú or anyone else uses is a matter of taste.