Debian Codegraph @

src/doc/manual/standards/conditions.txi

raw
1 @node Conditions
2 @section Conditions
3
4 @subsection C Reference
5 @cppdef ECL_HANDLER_CASE
6
7 @deffn Macro ECL_HANDLER_CASE
8 C macro for @clhs{m_hand_1.htm,handler-case}
9 @paragraph Synopsis
10 @example
11 @verbatim
12 ECL_HANDLER_CASE_BEGIN(env,names) {
13
14 } ECL_HANDLER_CASE(n,condition) { {
15
16 } ECL_HANDLER_CASE_END;
17 @end verbatim
18 @end example
19
20 @paragraph Description
21 @code{ECL_HANDLER_CASE_BEGIN} runs a block of C code with a set of error handlers bound to the names given by the list @var{names}. The subsequent @coderef{ECL_HANDLER_CASE} statements specify what to do when the @var{n}-th type of conditions is found, where @var{n} is an integer denoting the position of the name in the list @var{names}.
22
23 When a condition is signaled, ECL scans the list of signal handlers, looking for matches based on @code{typep}. If the match with the highest precedence belongs to the list @var{names}, ECL will perform a non-local transfer of control to the appropriate @coderef{ECL_HANDLER_CASE}, passing it a @var{condition} object as unique argument.
24
25 The following example shows how to establish a handler for @code{error} conditions. Note how the first value to @coderef{ECL_HANDLER_CASE} matches the position of the condition name in the list:
26
27 @example
28 @verbatim
29 cl_object error = ecl_make_symbol("ERROR","CL");
30 ECL_HANDLER_CASE_BEGIN(the_env, ecl_list1(error)) {
31 /* This form is evaluated with bound handlers */
32 output = cl_eval(1, form);
33 } ECL_HANDLER_CASE(1, condition) {
34 /* This code is executed when an error happens */
35 /* We just return the error that took place */
36 output = condition;
37 } ECL_HANDLER_CASE_END;
38 @end verbatim
39 @end example
40
41 @end deffn
42
43
44 @cppdef ECL_RESTART_CASE
45 @deffn Macro ECL_RESTART_CASE
46 C macro for @clhs{m_rst_ca.htm,restart-case}
47 @paragraph Synopsis
48 @example
49 @verbatim
50 ECL_RESTART_CASE_BEGIN(env,names) {
51
52 } ECL_RESTART_CASE(n,args) { {
53
54 } ECL_RESTART_CASE_END;
55 @end verbatim
56 @end example
57
58 @paragraph Description
59 @code{ECL_RESTART_CASE_BEGIN} runs a block of C code with a set of restarts bound to the names given by the list @var{names}. The subsequent @coderef{ECL_RESTART_CASE} statements specify what to do when the @var{n}-th restart is invoked, where @var{n} is an integer denoting the position of the name in the list @var{names}.
60
61 When the restart is invoked, it can receive any number of arguments, which are grouped in a list and stored in a new variable created with the name @var{args}.
62
63 The following example shows how to establish an @var{abort} and a @var{use-value} restart. Note how the first value to @coderef{ECL_RESTART_CASE} matches the position of the restart name in the list:
64
65 @example
66 @verbatim
67 cl_object abort = ecl_make_symbol("ABORT","CL");
68 cl_object use_value = ecl_make_symbol("USE-VALUE","CL");
69 ECL_RESTART_CASE_BEGIN(the_env, cl_list(2, abort, use_value)) {
70 /* This form is evaluated with bound restarts */
71 output = cl_eval(1, form);
72 } ECL_RESTART_CASE(1, args) {
73 /* This code is executed when the 1st restart (ABORT) is invoked */
74 output = ECL_NIL;
75 } ECL_RESTART_CASE(2, args) {
76 /* This code is executed when the 2nd restart (USE-VALUE) is invoked */
77 output = ECL_CAR(args);
78 } ECL_RESTART_CASE_END;
79 @end verbatim
80 @end example
81 @end deffn
82
83 @subsubsection ANSI dictionary
84 Common Lisp and C equivalence
85
86 @multitable @columnfractions .3 .7
87 @headitem Lisp symbol @tab C function
88 @item @clhs{f_abortc.htm,abort} @tab cl_object cl_abort(cl_narg narg, ...)
89 @item @clhs{f_break.htm,break} @tab [Only in Common Lisp]
90 @item @clhs{f_cell_e.htm,cell-error-name} @tab [Only in Common Lisp]
91 @item @clhs{f_cerror.htm,cerror} @tab cl_object cl_cerror(cl_narg narg, cl_object continue_format_control, cl_object datum, ...)
92 @item @clhs{f_comp_1.htm,compute-restarts} @tab cl_object cl_compute_restarts(cl_narg narg, ...)
93 @item @clhs{f_abortc.htm,continue} @tab cl_object cl_continue(cl_narg narg, ...)
94 @item @clhs{f_error.htm,error} @tab cl_object cl_error(cl_narg narg, cl_object datum, ...)
95 @item @clhs{f_find_r.htm,find-restart} @tab cl_object cl_find_restart(cl_narg narg, cl_object identifier, ...)
96 @item @clhs{m_hand_1.htm,handler-case} @tab ECL_HANDLER_CASE macro
97 @item @clhs{f_invali.htm,invalid-method-error} @tab cl_object cl_invalid_method_error (cl_narg narg, cl_object method, cl_object format, ...)
98 @item @clhs{f_invoke.htm,invoke-debugger} @tab [Only in Common Lisp]
99 @item @clhs{f_invo_1.htm,invoke-restart} @tab cl_object cl_invoke_restart(cl_narg narg, cl_object restart, ...)
100 @item @clhs{f_invo_2.htm,invoke-restart-interactively} @tab cl_object cl_invoke_restart_interactively(cl_object restart)
101 @item @clhs{f_mk_cnd.htm,make-condition} @tab cl_make_condition(cl_narg narg, cl_object type, ...)
102 @item @clhs{f_meth_1.htm,method-combination-error} @tab cl_object cl_method_combination_error(cl_narg narg, cl_object format, ...)
103 @item @clhs{f_abortc.htm,muffle-warning} @tab cl_object cl_muffle_warning(cl_narg narg, ...)
104 @item @clhs{f_rst_na.htm,restart-name} @tab [Only in Common Lisp]
105 @item @clhs{f_rst_ca.htm,restart-case} @tab ECL_RESTART_CASE macro
106 @item @clhs{f_signal.htm,signal} @tab [Only in Common Lisp]
107 @item @clhs{f_smp_cn.htm,simple-condition-format-control} @tab [Only in Common Lisp]
108 @item @clhs{f_smp_cn.htm,simple-condition-format-arguments} @tab [Only in Common Lisp]
109 @item @clhs{f_abortc.htm,store-value} @tab cl_object cl_store_value(cl_narg narg, ...)
110 @item @clhs{f_abortc.htm,use-value} @tab cl_object cl_use_value(cl_narg narg, ...)
111 @item @clhs{f_warn.htm,warn} @tab [Only in Common Lisp]
112 @end multitable