A symbol naming the defined Lisp function.
A string or a symbol specifying the foreign name of the function.
A foreign type name.
A Lisp object.
A foreign type name.
The lambda list to be used for the defined Lisp function.
A documentation string for the foreign function.
A foreign type.
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.
A symbol or string naming the module in which the foreign symbol is defined.
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.
foreign-name is the name of the function in the foreign source code. This is the default value of encoding when foreign-name is a string.
foreign-name is the literal name of the function in the foreign object code.
If foreign-name is a Lisp symbol, it must be translated and encoded. This is the default value of encoding if foreign-name is a symbol.
A suffix is automatically appended to the function name depending on the Windows operating system that LispWorks runs in. The suffix is "
" for Windows 95-based systems and "
" for Windows NT-based systems.
The number and types of the arguments of lisp-name must be given. 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 lambda-list .
, then the lambda list of the Lisp function
will contain these lambda-list-keywords too. Any argument following
can use the
syntax to provide a default value
is of the form
is always passed through to the foreign code and
is omitted from the lambda list of
. This is generally only useful when
type, where the value
will be ignored.
the foreign code is expected to be written in ANSI C. In particular single floats are passed through as single-floats whereas
causes them to be passed through as double floats. Similarly
causes double floats to be returned from C and
causes a single-floats to be returned. In both cases the type returned to Lisp is determined by
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
even if they do not appear in
is not supplied, the lambda list of
is generated from the list of
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.
optionally specifies the type of the foreign function's return value. When
is an 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 unspecified. 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). If
is :void or is omitted, then no value is returned.
is ignored on non-Windows platforms, where there is no calling convention issue. On Windows,
is the calling convention used to call Win32 API functions and matches the C declarator
. This is the default value.
is the default calling convention for C/C++ programs and matches the C declarator
is the name of a module registered using
- this prevents them being used by other
forms which do not specify a module.
LispWorks Foreign Language Interface User Guide and Reference Manual - 7 Dec 2011