Either a symbol naming the defined Lisp function, or a list containing the name of the Lisp function, the corresponding foreign function name and optionally an encoding option.
A symbol naming the defined Lisp function.
A symbol naming the foreign function.
A string containing the name of the foreign function.
An option controlling how the Lisp function name is translated into the function name in the foreign object code. The encoding option can be one of the following:
adds a suffix onto the function name which will automatically change depending on whether Lisp image is started up in the Windows NT or Windows 95 operating system. The suffix is "
" for Windows 95 and "
" for Windows NT.
Either an argument name, a list containing an argument name and a type, or a list of the form
. Lisp arguments may take any name, but the types must be accurately specified and listed in the same order as in the foreign function, unless otherwise specified using
The lambda list to be used for the defined Lisp function. If this is not specified, the lambda list is generated from the list of
keyword allows you to define the order in which the Lisp function takes its arguments to be different from the order in which the foreign function takes them, and to use standard lambda list keywords such as
. The default value of
A documentation string for the foreign function.
The type of the foreign function's return value.
The name of the keyword argument that is added to the lambda-list of the Lisp function when the result-type is an aggregate type.
The language in which the foreign source code is written. The default is
, the types of the arguments provided when the Lisp function is called are compared with the expected types and an error is raised if they do not match. Setting
overrides this check.
Specifies the module in which the foreign symbol is defined. If it is the name of a module registered using
defines a Lisp function which acts as an interface to a foreign language function, for example a C function. When the Lisp function is called its arguments are converted to the appropriate foreign representation before being passed to the specified foreign function. Once the foreign function exits, any return values are converted back from the foreign format into a Lisp format.
The number and types of the Lisp function's arguments must be given, and optionally the type of the return value may be specified too. The order in which the Lisp function takes its arguments can be different from the order expected by the foreign function, using the lambda-list argument.
types are useful with
. It is fairly common for a C function to return a value by setting the contents of an argument passed by reference (that is, as a pointer). This can be handled conveniently by using the
type, which dynamically allocates memory for the return value and passes a pointer to the C function. On return, the pointer is dereferenced and the value is returned as an extra multiple value from the Lisp function.
is a aggregate type, an additional keyword argument is placed in the lambda-list of the Lisp function. This keyword is named after the
argument or is called
if unspecifed. When calling the Lisp function, a foreign pointer must be supplied as the value of this keyword argument, pointing to an object of type
. The result of the foreign call is written into this object and the foreign pointer is returned as the primary value from the Lisp function. This allows the caller to maintain control over the lifetime of this object (in C this would typically be stored in a local variable).