2011-02-25 33 views
2

在Clozure Common Lisp 1.6上成功加载CFFI(ql:quickload "cffi"),我在*features*中有CFFI-FEATURES:X86 CFFI-FEATURES:UNIX :CFFI。我很好奇,但是为什么一些CFFI的功能与cffi-sys:前缀可见:在Clozure Common Lisp中使用CFFI的包前缀混淆

? (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的作品?

回答

2

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

命名一个包东西-SYS暗示它可能捆绑一些内部机械。

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

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

+0

好的,这是有道理的。总之,我应该坚持用'cffi:'来代替我的代码。 – FilipK