MNode* ml_progn (MNode* cell, MlEnv* mlenv) {
MNode* arg = cell->cdr ();
MNodePtr ans;
+ MNodePtr errfn;
+ std::vector<MNode*> keywords;
+ MNode* rest;
+ static paramList kwlist[] = {
+ {CharConst ("on-error"), false},
+ {NULL, 0, 0}
+ };
- ans = progn (arg, mlenv);
+ setParams (arg, 0, NULL, kwlist, &keywords, &rest);
+ if (keywords[0])
+ errfn = eval (keywords[0], mlenv);
+
+ try {
+ ans = progn (rest, mlenv);
+ } catch (ustring& msg) {
+ if (errfn ()) {
+ MNodePtr v;
+ MNodePtr ag;
+ ag = new MNode;
+ ag ()->set_car (mlenv->currentCell ());
+ v = execDefun (mlenv, errfn (), ag (), uEmpty);
+ } else {
+ throw (msg);
+ }
+ }
if (mlenv->breaksym ()
&& (mlenv->breaksym ()->isNil () || eq (mlenv->breaksym (), cell->car ()))) {
mlenv->setBreaksym (NULL);