%eclent; ]> Conditions
C Reference ECL_HANDLER_CASE C macro for handler-case ECL_HANDLER_CASE_BEGIN(env,names) { } ECL_HANDLER_CASE(n,condition) { { } ECL_HANDLER_CASE_END; Description ECL_HANDLER_CASE_BEGIN runs a block of C code with a set of error handlers bound to the names given by the list names. The subsequent ECL_HANDLER_CASE statements specify what to do when the n-th type of conditions is found, where n is an integer denoting the position of the name in the list names. When a condition is signaled, &ECL; scans the list of signal handlers, looking for matches based on typep. If the match with the highest precedence belongs to the list names, &ECL; will perform a non-local transfer of control to the appropriate ECL_HANDLER_CASE, passing it a condition object as unique argument. The following example shows how to establish a handler for ERROR conditions. Note how the first value to ECL_HANDLER_CASE matches the position of the restart name in the list: cl_object error = ecl_make_symbol("ERROR","CL"); ECL_RESTART_BEGIN(the_env, ecl_list1(error)) { /* This form is evaluated with bound handlers */ output = cl_eval(1, form); } ECL_HANDLER_CASE(1, condition) { /* This code is executed when an error happens */ /* We just return the error that took place */ output = condition; } ECL_RESTART_END; ECL_RESTART_CASE C macro for restart-case ECL_RESTART_CASE_BEGIN(env,names) { } ECL_RESTART_CASE(n,args) { { } ECL_RESTART_CASE_END; Description ECL_RESTART_CASE_BEGIN runs a block of C code with a set of restarts bound to the names given by the list names. The subsequent ECL_RESTART_CASE statements specify what to do when the n-th restart is invoked, where n is an integer denoting the position of the name in the list names. 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 args. The following example shows how to establish an ABORT and a USE-VALUE restart. Note how the first value to ECL_RESTART_CASE matches the position of the restart name in the list: cl_object abort = ecl_make_symbol("ABORT","CL"); cl_object use_value = ecl_make_symbol("USE-VALUE","CL"); ECL_RESTART_BEGIN(the_env, cl_list(2, abort, use_value)) { /* This form is evaluated with bound restarts */ output = cl_eval(1, form); } ECL_RESTART_CASE(1, args) { /* This code is executed when the 1st restart (ABORT) is invoked */ output = Cnil; } ECL_RESTART_CASE(2, args) { /* This code is executed when the 2nd restart (ABORT) is invoked */ output = ECL_CAR(args); } ECL_RESTART_END; Conditions C dictionary &ANSI-C-Dict; Lisp symbol C function abort cl_object cl_abort(cl_narg narg, ...) break cl_object cl_break() cell-error-name &OCL; cerror cl_object cl_cerror(cl_narg narg, cl_object continue_format_control, cl_object datum, ...) compute-restarts cl_object cl_compute_restarts(cl_narg narg, ...) continue cl_object cl_continue(cl_narg narg, ...) error cl_object cl_error(cl_narg narg, cl_object datum, ...) find-restart cl_object cl_find_restart(cl_narg narg, cl_object identifier, ...) handler-case ECL_HANDLER_CASE macro invalid-method-error &OCL; invoke-debugger cl_object cl_invoke_debugger(cl_object condition) invoke-restart cl_object cl_invoke_restart(cl_narg narg, cl_object restart, ...) invoke-restart-interactively cl_object cl_invoke_restart_interactively(cl_object restart) make-condition cl_object cl_make_condition(cl_narg narg, cl_object type) method-combination-error &OCL; muffle-warning cl_object cl_muffle_warning(cl_narg narg, ...) restart-name &OCL; restart-case ECL_RESTART_CASE macro signal cl_object cl_signal(cl_narg narg, cl_object datum, ...) simple-condition-format-control &OCL; simple-condition-format-arguments &OCL; store-value cl_object cl_store_value(cl_narg narg, ...) use-value cl_object cl_use_value(cl_narg narg, ...) warn cl_object cl_warn(cl_narg narg, cl_object datum, ...) Description