[Ecls-list] Some Embedding help.

Juan Jose Garcia-Ripoll juanjose.garciaripoll at googlemail.com
Wed Aug 6 08:46:17 UTC 2008


On Wed, Aug 6, 2008 at 2:14 AM, John Connors <johnc at yagc.ndo.co.uk> wrote:
> I've been playing a little with ECLs and GLG3d, see:
> http://badbyteblues.blogspot.com/2008/07/what-next.html

Nice. If you progress any further and find this a viable project, I
would not mind adding a screenshot to the project page.

> The embedded REPL's evaluator is just a simple invocation of
> si_safe_eval as suggested in numerous places.
> But I'm unsure of two things. The first is what to do when si_safe_eval
> returns multiple-values? Should the results be on the VALUES stack?

Only the principal value is returned directly, but the rest should be
in the values stack.

(defun safe-eval (form env err-value)
  (catch 'si::protect-tag
    (let* ((*debugger-hook*
            #'(lambda (condition old-hooks)
                (throw 'si::protect-tag condition))))
      (return-from safe-eval (eval-with-env form env))))
  err-value)

> Secondly, I've been unable to get debugging working. I can hook a
> debugging function and use it, but can't figure out how to return from
> it safely - there don't seem to be any restarts.

Well, first note that the definition of SAFE-EVAL is only valid if you
do not replace the debugger hook.

Then, restarts are not set up automatically by ECL. The only case
where this happens is for continuable errors, and other errors with
simple recovery: undefined variables, wrong type arguments, etc. In
those cases, the default debugger does two things: it prints out a
list of available restarts and adds some new commands to the debugger
for invoking them.

But I presume this is not what you want, is it? You probably have a
situation in which the computation is broken and want to return
completely from the interpreted environment, the equivalent of :q in
the ordinary interpreter. There are several possibilities:

1) If you are using safe-eval, you can (throw 'si::protect-tag ...) and exit.
2) If you want something more elaborated, you can write your own
evaluation routine and let it set up either a catch statement or some
restart.

Hope this helps

Juanjo

-- 
Instituto de Física Fundamental
CSIC, Serrano, 113, Madrid 28040 (Spain)
http://juanjose.garciaripoll.googlepages.com


More information about the ecl-devel mailing list