MadPhysicist
MadPhysicist

Reputation: 5831

External vs Internal Symbols in Common Lisp Package

What is the difference between them in the context of a Common Lisp package? I am reading through SLIME documentation and some commands mention that extensively.

Upvotes: 2

Views: 1240

Answers (2)

Ehvince
Ehvince

Reputation: 18375

What is the syntax ? The symbols you export are external.

(in-package :cl-user)
(defpackage str
  (:use :cl)
  (:export
   :trim-left
   ))

(in-package :str)

;; exported: can be accessed with `str:trim-left`.
(defun trim-left (s)
  "Remove whitespaces at the beginning of s. "
  (string-left-trim *whitespaces* s))

;; forgot to export: can still access it with `str::trim-right`.
(defun trim-right (s)
  "Remove whitespaces at the end of s."
  (string-right-trim *whitespaces* s))

Upvotes: 8

siehe-falz
siehe-falz

Reputation: 469

The author of a Common Lisp package can export a symbol for the user of the package. Then the symbol is an external symbol and you can access it with package-name:external-symbol-name.

Internal symbols are not meant for the user but can be accessed with package-name::symbol-name

More explanations are in Peter Seibel's book and Common Lisp the Language

Upvotes: 5

Related Questions