The following example shows a simple file using the package mechanism.
(defpackage "MYPACKAGE" (:use "CL")) (in-package "MYPACKAGE") (export '(h k)) (defun g (x) (+ x 1)) (defun h (x) (+ (g x) 2)) (defun k (x) (h x))Within the package all local symbols are available: h and k both use the unexported function g. To use the exported symbols outside mypackage either you need to import the symbols into your package, or you can refer to them by prefixing their names with the package name and a colon:
> (mypackage:h 1) 4Since g is not exported it cannot be accessed in this way:
> (mypackage:g 1) Error: external symbol not found - "G"However Lisp philosophy is to not close off access to any internals unless doing so would allow significant performance improvements; therefore it is possible to access an internal symbol using a double colon:
> (mypackage::g 1) 2Thus the package mechanism does not prevent access to internal symbols but it does prevent inadvertent access.