Common Lisp 项目的代码结构

相比于 Python 项目简单清晰的目录结构,Common Lisp 的项目结构要复杂不少,尤其是大型项目。但当你知道每个文件/目录的作用时,会发现这目录结构也不复杂。 以 Postmodern 项目为例,看看实际项目是怎样组织代码的。 该项目目录结构如下: ├── cl-postgres/... ├── cl-postgres.asd ├── postmodern/ │ ├── connect.lisp │ ├── ... │ ├── package.lisp │ └── tests │ ├── ... │ ├── test-package.lisp │ └── tests.lisp ├── postmodern.asd ├── simple-date/... ├── simple-date.asd ├── s-sql/... ├── s-sql.asd └── ... 这里省略了部分目录和文件,但不影响我们解读该目录结构。可以点击链接了解完整的目录结构。 首先看最外层的文件,这里列出的都是以 .asd 为后缀的文件,这些文件描述了源代码间的依赖关系,使它们能按正确的顺序进行编译和加载。而这依靠的便是 ASDF 自动编译系统。 ASDF,全称 Another System Definition Facility,该构建系统指定了 Common Lisp 程序中各系统的组成及控制各组件能按正确的顺序进行编译、加载和测试等等。 ASDF, or Another System Definition Facility, is a build system: a tool for specifying how systems of Common Lisp software are made up of components (sub-systems and files), and how to operate on these components in the right order so that they can be compiled, loaded, tested, etc....

2020-06-07 · 1 分钟 · 191 字

Common Lisp 中的相等性判断

Common Lisp 判断对象是否相等的函数比较多,这里记录一下目前遇到的用于判断相等的函数。 相等性判断函数 = 函数 = 用于判断数值(numbers)是否相等(不判断类型),并且只能用于判断数值类型的元素。 语法: ;;; = &rest numbers+ => generalized-boolean (= 1 1.0 #c(1 0)) ; => T CHAR= / STRING= char= 用于判断多个字符是否相等,区分大小写。此外,不同实现中如果定义两个字符不同,char= 返回 NIL。 If two characters differ in any implementation-defined attributes, then they are not char=. 语法: ;;; char= &rest characters+ => generalized-boolean (char= #\d #\d) ; => T string= 用于判断多个字符串是否相等,区分大小写。 语法: ;;; string= string1 string2 &key start1 end1 start2 end2 => generalized-boolean (string= "foo" "foo") ; => T 可以比较两个字符串中指定的子序列。...

2020-06-03 · 2 分钟 · 270 字