Creates a dynamic-extent foreign pointer which points to the data in a given Lisp array while the forms are executed.
A variable to be bound to the foreign pointer.
A Lisp array.
An index into the Lisp array. The default is
A foreign type. The default is
A list of forms.
The value of the last form in
enables the data in a Lisp array (a string or a byte array) to be shared directly with foreign code, without making a copy. A dynamic-extent pointer to the array's data can be used within
wherever the :pointer foreign type allows.
creates a dynamic extent foreign pointer, with element type
, which is initialized to point to the element of
This foreign pointer is bound to
, the forms of
are executed and the value of the last form returned.
Pointers created with this macro must be used with care. There are three restrictions:
must be static, for example allocated as shown below.
The pointer has dynamic extent and
is guaranteed to be preserved only during the execution of
. If you keep the value of the pointer, you must also preserve
that is you must ensure it is not garbage-collected.
Lisp strings and arrays are not null-terminated, therefore foreign code must only access the data of
up to its known length.
(make-array 3 :element-type '(unsigned-byte 8)
:initial-contents '(65 77 23)
(ptr vector :start 1 :type :unsigned-byte)
LispWorks Foreign Language Interface User Guide and Reference Manual - 14 Mar 2008