Anniepoo
Anniepoo

Reputation: 2162

ISO error classification for multiple definition in Prolog DSL

I'm building a DSL that uses names for procedures (essentially) that must be unique.

It's unclear what sort of error term to use to represent a second definition.

existence_error sorta kinda fits, but I'm uncomfortable with it. It seems to imply missing definition, not multiple definition.

permission_error(modify, procedure, Name/Arity) seems promising, but seems to imply "some people could do this, but not you". Without further enlightenment, I'll use this.

syntax_error sorta kinda fits, but is defined as being for read_term only.

Should I define my own here? The spec says 'use these when you can'.

Upvotes: 1

Views: 125

Answers (1)

user502187
user502187

Reputation:

In the old times there was no SWISH or Pengines where a Prolog prozessor was used by multiple users, and probably through batch processing there wasn't much awareness that resources could be blocked by other users. So the explanation of the error term permission_error/3 is mostlikely as SICStus Prolog describes it here:

"A permission error occurs when an operation is attempted that is among the kinds of operation that the system is in general capable of performing, and among the kinds that you are in general allowed to request, but this particular time it isn't permitted."
http://sicstus.sics.se/sicstus/docs/4.0.4/html/sicstus/ref_002dere_002derr_002dper.html

But I agree, from the name of the error term, we would expect its application range only some violation of access or modification rules, and not some semantic restrictions over syntactic structure such as a DSL.

But you are probably not the only one that has these problems. If your Prolog system has a messaging subsystem, where you can easily associate error terms with user friendly text, I don't see any reasons to not introduce new error terms.

You could adopt the follow error terms already suggested by SICStus Prolog and not found in the ISO core standard:

"A consistency error occurs when two otherwise valid values or operations have been specified that are inconsistent with each other." http://sicstus.sics.se/sicstus/docs/4.0.4/html/sicstus/ref_002dere_002derr_002dcns.html

"A context error occurs when a goal or declaration appears in the wrong place. There may or may not be anything wrong with the goal or declaration as such; the point is that it is out of place." http://sicstus.sics.se/sicstus/docs/4.0.4/html/sicstus/ref_002dere_002derr_002dcon.html

Especially SWI-Prolog has such a messaging subsystem and SWI-Prolog has long said good-bye to interoperability with other Prolog systems. So the only danger if you would use SWI-Prologs messaging is a certain lock-in, which might not bother you.

Upvotes: 1

Related Questions