[Grace-core] Exceptions in Grace

Andrew P Black andrew.p.black at gmail.com
Fri Jul 31 16:30:56 PDT 2015


On 31 Jul 2015, at 10:42, Kim Bruce <kbbruce47 at gmail.com> wrote:

> When a new exception kind is created in Grace, e.g.,
> 
> def DateRangeException = EnvironmentException.refine("date range exception")
> 
> what is the purpose of the string parameter to refine.  It doesn't seem to be related to the message printed.  The spec says nothing about it.

In minigrace, the `refine` string actually distinguishes the various kinds of Exception.  That is, two exceptions are equal iff they have the same parent and the equal refine strings.   

We might want to change that, and make Exceptions singleton objects.   However, the way the prelude is presently built, it’s actually rather hard to have a single occurrence of some of the definitions of the Exceptions.

This is a change to think about when we change all of the exception names to lower case.  The spec should in any case define Exception equality one way or the other.

We are also inconsistent whether the refine string is like an identifier or like a message.  That is, should we write

	def NoSuchMethod = ProgrammingError.refine “NoSuchMethod”

or

	def NoSuchMethod = ProgrammingError.refine “no such method”

Bear in mind that then raised, we typically write something like

	NoSuchMethod.raise “no method {foo} in object {bar}"


	Andrew
  




More information about the Grace-core mailing list