I'm in the middle of developing a new programming language to solve some business requirements, and this language is targeted at novice users. So there is no support for exception handling in the language, and I wouldn't expect them to use it even if I added it.
I've reached the point where I have to implement the divide operator, and I'm wondering how to best handle a divide by zero error?
I seem to have only three possible ways to handle this case.
- Ignore the error and produce
0
as the result. Logging a warning if possible. - Add
NaN
as a possible value for numbers, but that raises questions about how to handleNaN
values in other areas of the language. - Terminate the execution of the program and report to the user a severe error occurred.
Option #1 seems the only reasonable solution. Option #3 is not practical as this language will be used to run logic as a nightly cron.
What are my alternatives to handling a divide by zero error, and what are the risks with going with option #1.
reject "Foo"
was implemented, but simply that it rejects a document if it contains the keywordFoo
. I try to make the language as easy to read using terms the user is familiar with. Giving a user their own programming language empowers them to add business rules without depending upon technical staff.