开发者

Confusion with package prefixes using CFFI in Clozure Common Lisp

Having successfully loaded CFFI on Clozure Common Lisp 1.6 with (ql:quickload "cffi"), I have CFFI-FEATURES:X86 CFFI-FEATURES:UNIX :CFFI in *features*. I'm curious however why some of CFFI's functions are visible with the cffi-sys: prefix:

? (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."

while some others work also with 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 restar开发者_如何学Cts.
> If continued: Use the internal symbol CFFI-SYS:%FOREIGN-FUNCALL
> Type :? for other options.

Looking into cffi_0.10.6/src/cffi-openmcl.lisp I can see (defpackage #:cffi-sys ..., so how come that cffi:null-pointer works?


In Lisp there are some naming conventions. Some are widely used, some not.

Naming a package something-SYS hints that it may bundle some internal machinery.

Naming a symbol %SOMETHING hints that it is an internal or implementation specific functionality and is not intended to be used directly in user code.

So from the naming I would guess that cffi-sys:%foreign-funcall is a function which is used internally by CFFI, but not intended to be used by the user. Thus this symbol is then also not exported from the main package CFFI. Possibly there is another symbol exported from the CFFI package which provides the functionality in a more portable or convenient way.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜