} | (
A string or symbol naming the Lisp callable function created.
By default, LispWorks performs automatic name encoding to translate foreign-name
modifies the function name on Windows, as described for define-foreign-function.
The language in which the foreign calling code is written. The default is
The FLI type of the Lisp foreign callable function's return value which is passed back to the calling code.
A variable which will be bound to a foreign pointer into which the result should be written when the result-type is an aggregate type.
, the result of the foreign callable function, produced by
, is checked to see if matches the
, and an error is raised if they do not match. Setting
overrides this check.
The arguments of the Lisp foreign callable function. Each argument can consist either of an
, in which case LispWorks assumes it is an
, or an
, which is a FLI type.
A list of forms which make up the Lisp foreign callable function.
defines a Lisp function that can be called from a foreign language, for example from a C function. When the Lisp function is called, data passed to it is converted to the appropriate FLI representation, which is translated to an appropriate Lisp representation for the Lisp part of the function. Once the callable function exits, any return values are converted back into a FLI format to be passed back to the calling language.
When you use
, you need to set
to the value that you want to return in that reference. That value is then converted and stored into the pointer supplied by the calling foreign function. This is done after the visible body of your
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 an aggregate type, an additional variable is bound in the body to allow the value of the function to be returned (the value returned by the body is ignored). This argument is named after the
argument or is named
in the current package if unspecified. While the body is executing, the variable will be bound to a foreign pointer that points to an object of the type
. The body must set the slots in this foreign object in order for the value to be returned to the caller.
(make-pointer :symbol-name "Foo")
is used so you could retain that explicitly (see the
LispWorks Delivery User Guide
for details, and take care to specify the package). However it is simpler to name the foreign callable with your Lisp symbol, and pass that to make-pointer. This call will keep your foreign callable in the delivered application:
The foreign callable function,
, can now be called from a foreign language. We can mimic a foreign call by using the define-foreign-function macro to define a FLI function to call