2011-02-25 35 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