在Clozure Common Lisp中使用CFFI与包前缀混淆

时间:2011-02-25 15:05:50

标签: common-lisp

使用(ql:quickload "cffi")在Clozure Common Lisp 1.6上成功加载CFFI后,我在CFFI-FEATURES:X86 CFFI-FEATURES:UNIX :CFFI中有*features*。我很好奇为什么一些CFFI的函数可以用cffi-sys:前缀显示:

? (documentation 'cffi:null-pointer 'function)
"Construct and return a null pointer."

? (documentation 'cffi-sys:%foreign-funcall 'function)
"Perform a foreign function call, document it more later."

而其他一些人也使用cffi:

? (documentation 'cffi:null-pointer 'function)
"Construct and return a null pointer."

? (documentation 'cffi:%foreign-funcall 'function)
> Error: Reader error: No external symbol named "%FOREIGN-FUNCALL" in package #<Package "CFFI">.
> While executing: CCL::%PARSE-TOKEN, in process listener(1).
> Type :GO to continue, :POP to abort, :R for a list of available restarts.
> If continued: Use the internal symbol CFFI-SYS:%FOREIGN-FUNCALL
> Type :? for other options.

展望cffi_0.10.6/src/cffi-openmcl.lisp我可以看到(defpackage #:cffi-sys ...,那么cffi:null-pointer如何运作?

1 个答案:

答案 0 :(得分:2)

在Lisp中有一些命名约定。有些被广泛使用,有些则没有。

命名包 something-SYS 提示它可能捆绑一些内部机器。

命名符号%SOMETHING 提示它是内部或特定于实现的功能,不能直接在用户代码中使用。

因此从命名我会猜测 cffi-sys:%foreign-funcall 是一个由CFFI内部使用的函数,但不打算由用户使用。因此,该符号也不会从主包CFFI导出。可能还有另一个从CFFI包中导出的符号,它以更便携或更方便的方式提供功能。

相关问题