Npt documentation.
Reference: ANSI Common Lisp npt
The following function specifications are described in lisp.h
.
void lisp_push_control(addr *ret);
int lisp_pop_control_(addr control);
int lisp_push_special_(addr symbol, addr value);
int lisp_push_special8_(const void *name, addr value);
int lisp_push_special16_(const void *name, addr value);
int lisp_push_special32_(const void *name, addr value);
int lisp_get_special_(addr x, addr symbol);
int lisp_get_special8_(addr x, const void *name);
int lisp_get_special16_(addr x, const void *name);
int lisp_get_special32_(addr x, const void *name);
int lisp_set_special_(addr symbol, addr value);
int lisp_set_special8_(const void *name, addr value);
int lisp_set_special16_(const void *name, addr value);
int lisp_set_special32_(const void *name, addr value);
int lisp_defvar_(addr symbol);
int lisp_defvar8_(const void *str);
int lisp_defvar16_(const void *str);
int lisp_defvar32_(const void *str);
void lisp_catch(addr symbol);
int lisp_throw_(addr symbol);
int lisp_handler_bind_(addr name, addr call);
int lisp_handler_case_(addr name, addr call);
void lisp_handler_reverse(void);
void lisp_restart_make(addr x, addr name, addr call, int casep);
void lisp_restart_interactive(addr restart, addr call);
void lisp_restart_report(addr restart, addr call);
void lisp_restart_test(addr restart, addr call);
void lisp_restart_push(addr restart);
void lisp_restart_reverse(void);
Functions for allocating and releasing stack frame space.
void lisp_push_control(addr *ret);
int lisp_pop_control_(addr control);
lisp_push_control
void lisp_push_control(addr *ret);
: ret, New stack frame Output
Allocates a new stack frame.
The stack frame is mainly used for hold variables.
lisp_pop_control_
int lisp_pop_control_(addr control);
: control, Stack frames to be released.
Input: Non-zero when escaping. Return
Releases the stack frame.
The current stack frame is also held by the execution environment, and it is an error if the argument control
is different from the current stack frame.
This function can also be used for escape.
It is an error if control
is a hold variable.
Functions for manipulating special variables.
int lisp_push_special_(addr symbol, addr value);
int lisp_push_special8_(const void *name, addr value);
int lisp_push_special16_(const void *name, addr value);
int lisp_push_special32_(const void *name, addr value);
int lisp_get_special_(addr x, addr symbol);
int lisp_get_special8_(addr x, const void *name);
int lisp_get_special16_(addr x, const void *name);
int lisp_get_special32_(addr x, const void *name);
int lisp_set_special_(addr symbol, addr value);
int lisp_set_special8_(const void *name, addr value);
int lisp_set_special16_(const void *name, addr value);
int lisp_set_special32_(const void *name, addr value);
lisp_push_special_
int lisp_push_special_(addr symbol, addr value);
: symbol, symbol.
Input: value, Object.
Input: Non-zero when escaping. Return
Adds a special variable of symbol
to the current stack frame.
The value
is the initial value of the special variable, which is unbound
if it is null.
If symbol
and value
are hold variables, the stored value will be used.
lisp_push_special8_
int lisp_push_special8_(const void *name, addr value);
int lisp_push_special16_(const void *name, addr value);
int lisp_push_special32_(const void *name, addr value);
: name, Unicode string.
Input: value, Object.
Input: Non-zero when escaping. Return
Find the symbol name
in the current package and add a special variable.
The value
is the initial value of the special variable, which is unbound
if it is null.
If symbol
and value
are hold variables, the stored value will be used.
See the lisp_string8_
function for details on Unicode strings.
lisp_push_special16_
See lisp_push_special8_
.
lisp_push_special32_
See lisp_push_special8_
.
lisp_get_special_
int lisp_get_special_(addr x, addr symbol);
: symbol, symbol
Input: x, Hold variable.
Output: Non-zero when escaping. Return
Get the value of the special variable.
If the retrieved value is unbound
, NULL is stored.
The NULL value stored in the hold variable can be checked with the lisp_null_p
function.
If symbol
is a hold variable, its content will be used.
lisp_get_special8_
int lisp_get_special8_(addr x, const void *name);
int lisp_get_special16_(addr x, const void *name);
int lisp_get_special32_(addr x, const void *name);
: name, Unicode string.
Input: x, Hold variable. Output
Find the symbol name
in the current package and get the value of the special variable.
If the retrieved value is unbound
, NULL is stored.
The NULL value stored in the hold variable can be checked with the lisp_null_p
function.
See the lisp_string8_
function for details on Unicode strings.
lisp_get_special16_
See lisp_get_special8_
.
lisp_get_special32_
See lisp_get_special8_
.
lisp_set_special_
int lisp_set_special_(addr symbol, addr value);
: symbol, symbol.
Input: value, Object.
Input: Non-zero when escaping. Return
Sets the value to the special variable.
If value
is null, unbound
is set.
If symbol
or value
is a hold variable, its content will be used.
lisp_set_special8_
int lisp_set_special8_(const void *name, addr value);
int lisp_set_special16_(const void *name, addr value);
int lisp_set_special32_(const void *name, addr value);
: name, Unicode string.
Input: value, Object.
Input: Non-zero when escaping. Return
Find the symbol name
in the current package and add a special variable.
If value
is null, unbound
is set.
See the lisp_string8_
function for details on Unicode strings.
lisp_set_special16_
See lisp_set_special8_
.
lisp_set_special32_
See lisp_set_special8_
.
Functions of the defvar
.
int lisp_defvar_(addr symbol);
int lisp_defvar8_(const void *str);
int lisp_defvar16_(const void *str);
int lisp_defvar32_(const void *str);
lisp_defvar_
int lisp_defvar_(addr symbol);
: symbol, symbol.
Input: Non-zero when escaping. Return
Make symbol
a special variable.
If symbol
or value
is a hold variable, its content will be used.
lisp_defvar8_
int lisp_defvar8_(const void *str);
int lisp_defvar16_(const void *str);
int lisp_defvar32_(const void *str);
: str, Unicode string.
Input: Non-zero when escaping. Return
Make the symbol represented by str
a special variable.
See the lisp_string8_
function for details on Unicode strings.
lisp_defvar16_
See lisp_defvar8_
.
lisp_defvar32_
See lisp_defvar8_
.
Functions of catch
and throw
.
void lisp_catch(addr symbol);
int lisp_throw_(addr symbol);
lisp_catch
void lisp_catch(addr symbol);
: symbol, symbol. Input
Register a symbol for catch
in the current stack frame.
If symbol
or value
is a hold variable, its content will be used.
lisp_throw_
int lisp_throw_(addr symbol);
: symbol, symbol.
Input: Non-zero. Return
Execute throw
with the symbol
argument.
It will search back through the stack frame and start escaping if it finds a symbol
for catch
.
If symbol
is not found, error
will be raised.
If symbol
or value
is a hold variable, its content will be used.
The handler-bind
and handler-case
functions.
int lisp_handler_bind_(addr name, addr call);
int lisp_handler_case_(addr name, addr call);
void lisp_handler_reverse(void);
lisp_handler_bind_
int lisp_handler_bind_(addr name, addr call);
: name, Symbol or condition.
Input: call, Function object.
Input: Non-zero when escaping. Return
Register the code for handler-bind
in the current stack frame.
If name
is symbol
, find-class
will be called.
call
specifies a function object that takes one argument.
If name
and call
are hold variables, the contents will be used.
lisp_handler_case_
int lisp_handler_case_(addr name, addr call);
: name, Symbol or condition.
Input: call, Function object.
Input: Non-zero when escaping. Return
Register the code for handler-case
in the current stack frame.
If name
is symbol
, find-class
will be called.
call
specifies a function object that takes one argument.
If name
and call
are hold variables, the contents will be used.
lisp_handler_reverse
void lisp_handler_reverse(void);
Put the handler list in reverse order.
You can register multiple lisp_handler_bind_
and lisp_handler_case_
, but since they are added to the current stack frame with push
, the evaluation order will be reversed. However, since they are added to the current stack frame by push
, the order of evaluation is not in the order of registration but in the reverse order.
Therefore, this function can be used to reverse the order of the handler list.
Functions of restart
.
void lisp_restart_make(addr x, addr name, addr call, int casep);
void lisp_restart_interactive(addr restart, addr call);
void lisp_restart_report(addr restart, addr call);
void lisp_restart_test(addr restart, addr call);
void lisp_restart_push(addr restart);
void lisp_restart_reverse(void);
lisp_restart_make
void lisp_restart_make(addr x, addr name, addr call, int casep);
: name, Symbol or NULL.
Input: call, Function object.
Input: casep, `restart-bind` is 1, `restart-case` is non-zero.
Input: x, Hold variable. Output
Creates a restart
object.
name
is the name, or NIL
if it is NULL
.
call
specifies a function object.
casep
is an argument to distinguish between restart-bind
and restart-case
, and should be non-zero if you want to specify restart-case
.
This function creates a restart
object, but does not register it into the stack frame.
If name
or call
is a hold variable, its content will be used.
lisp_restart_interactive
void lisp_restart_interactive(addr restart, addr call);
: restart, Restart object.
Input: call, Function object. Input
Sets the restart
object to the interactive code.
call
specifies a function to call with no arguments.
If call
is NULL
, it is not specified.
If restart
and call
are hold variables, the contents will be used.
lisp_restart_report
void lisp_restart_report(addr restart, addr call);
: restart, Restart object.
Input: call, Function object. Input
Set the restart
object to the report code.
call
specifies the function to call with one argument.
If call
is NULL
, it is not specified.
If restart
and call
are hold variables, the contents will be used.
lisp_restart_test
void lisp_restart_test(addr restart, addr call);
: restart, Restart object.
Input: call, Function object. Input
Sets the restart
object to the test code.
call
specifies the function to call with one argument.
If call
is NULL
, it is not specified.
If restart
and call
are hold variables, the contents will be used.
lisp_restart_push
void lisp_restart_push(addr restart);
: restart, Restart object. Input
Registers restart
with the current stack frame.
If restart
is a hold variable, use its contents.
lisp_restart_reverse
void lisp_restart_reverse(void);
Put the restart list in reverse order.
Although multiple lisp_restart_push
can be registered, they are added to the current stack frame with push
. However, since they are added to the current stack frame by push
, the order of evaluation is not in the order of registration but in the reverse order.
Therefore, this function can be used to reverse the order of the restart list.