[serene] [spec] Exceptions and errors specification

  • From: Sameer Rahmani <lxsameer@xxxxxxx>
  • To: serene@xxxxxxxxxxxxx
  • Date: Sun, 01 Nov 2020 16:32:20 +0000

Hey folks,

Hope you're doing well. Since the last discussion around implementing an
interpreter to bootstrap the compiler we need to come up with the
language specification gradually. So I start with what is necessary at
any given time.

As the topic suggests I'd like to know you idea on error handling and
exceptions. Personally and according to the goals of this project (as
discussed earlier) I prefer simplicity over a complex design. I think
having exceptions in the classic terms of exceptions are too complicated
and against the functional design because they easily break the purity of
functions. Therefor, Therefor I think, Either a monadic error handling
like a Maybe monad or even a simpler approach to error handling like
what Golang is using might be more suitable for a Lisp. This way we can
avoid breaking the functions purity as much as possible.

Our errors and exceptions categorized into two categorize:

A) Those which stops the execution flow like panics
B) Those which can be handled

For type A I think a simple `panic!` function similar to Rust would be
good enough and for the type B I think a list with a special format
could be a good choices. Something like a `error` function with two
multi-arity. `(error msg)` and `(error msg type)` which `msg` can be a
string and the `type` can be a keyword describing the type of the error.

Let's call this v0.1 of the exception spec.

What do you think ?

Cheers
Sameer

Other related posts:

  • » [serene] [spec] Exceptions and errors specification - Sameer Rahmani