ECL_RESTART_CASE — C macro for restart-case


} ECL_RESTART_CASE(n,args) { {


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);