Definición del paquete Common Lisp

In Common Lisp package definition, what is the difference between

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

(in-package #:foo)


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

(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

1 Respuestas

: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 y 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 or anyone else uses is a matter of taste.

respondido 08 nov., 11:17

Thank you for the answer. I will adopt uninterned symbols to avoid some clashes in the namespace, as this link shows… . I think is the better approach. - csgui

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.