在使用(ql:quickload "cffi")在Clozure Common Lisp1.6上成功加载CFFI之后,我在*features*中使用了CFFI-FEATURES:X86 CFFI-FEATURES:UNIX :CFFI。然而,我很好奇为什么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是如何工作的呢?
发布于 2011-02-26 16:57:00
在Lisp中有一些命名约定。有些被广泛使用,有些则没有。
命名一个包-SYS暗示它可能捆绑了一些内部机制。
命名一个符号%SOMETHING暗示它是一个内部或实现特定的功能,并不打算直接在用户代码中使用。
因此,从命名看,我猜想CFFI sys:%foreign-funcall是一个供CFFI内部使用的函数,但并不打算由用户使用。因此,此符号也不会从主包CFFI中导出。可能还有另一个从CFFI包导出的符号,它以一种更便携或更方便的方式提供了功能。
https://stackoverflow.com/questions/5118790
复制相似问题