Scieneer Common Lisp 1.3.9 online documentation

alien:defcallback name (result-type &rest arg-specs) &parse-body (body decls doc)[Macro]

(defcallback name (result-type {(arg-name arg-type)}*) {doc-string} {decls}* {form}*)

Defined a named callback lisp function of the specified name. The namespace of callback functions is separate from the lisp function namespace.

If the callback is already defined then the callback function is redefined but the callback SAP remains the same so that foreign code calling the callback calls the new function. If the arguments are not compatible then a continuable error is signaled with a range of restart options.

The address of the callback is returned by alien:callback-sap, and this address may be passed to foreign code to call back into lisp. The arg-name is a symbol that names the argument, and the arg-type is the C-Type of the argument. The result-type is the C-Type for the function return value and c-call:void may be used to specify a function with no result.

The callback SAP may change when lisp is restarted so care needs to be taken not to store and use stale addresses.