ocaml / oloop

Evaluate code through the OCaml toploop for inclusion in educational material.
ISC License
12 stars 5 forks source link

avoid separation of eval_error and error #13

Open agarwal opened 9 years ago

agarwal commented 9 years ago

In Oloop, we factor out eval_error from error purely because with sexp doesn't work on exn. Is there really no workaround? How come it is possible to convert exn to and from Error.t, and Error.t supports sexp?

Chris00 commented 9 years ago

One possibility would be to consider that `Internal_error is actually an error that the user should not handle (at least not locally, he probably wants to propagate it for some time) and thus that it should be converted to Error.t. If an exception is meant to be handled, it should be added to invalid_phrase.

agarwal commented 9 years ago

I think it's better to leave it explicit.

If an exception is meant to be handled, it should be added to invalid_phrase.

Yes, but how? Isn't that the problem, that we cannot include exceptions within invalid_phrase because they are not sexp-able.

Chris00 commented 9 years ago

On Tue, 14 Apr 2015 12:46:36 -0700, Ashish Agarwal wrote:

I think it's better to leave it explicit.

| If an exception is meant to be handled, it should be added to invalid_phrase. Yes, but how? Isn't that the problem, that we cannot include exceptions within invalid_phrase because they are not sexp-able.

Like the previous ones: oloop-top transforms the exception into a polymorphic variant.

agarwal commented 9 years ago

So we'd still have the catch-all `Internal_error, which we can't make sexp-able? Sure, then we can always add specific additional errors when desired.

Chris00 commented 9 years ago

If you list every compiler error, you can make it sexp-able. If you miss one, the oloop-top program will stop (or be taught to ignore/log it). None of this is very satisfactory.