【发布时间】:2017-12-12 22:28:50
【问题描述】:
在 Common Lisp 包的上下文中,它们之间有什么区别?我正在阅读 SLIME 文档,一些命令广泛地提到了这一点。
【问题讨论】:
标签: package lisp common-lisp sbcl
在 Common Lisp 包的上下文中,它们之间有什么区别?我正在阅读 SLIME 文档,一些命令广泛地提到了这一点。
【问题讨论】:
标签: package lisp common-lisp sbcl
语法是什么?你export 的符号是外部的。
(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))
【讨论】:
Common Lisp 包的作者可以为包的用户导出符号。那么这个符号就是一个外部符号,你可以用package-name:external-symbol-name来访问它。
内部符号不是供用户使用的,但可以通过package-name::symbol-name 访问
【讨论】: