Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Where can I find explanation of exceptions?

49 views
Skip to first unread message

ccwu

unread,
Jan 14, 2018, 7:00:15 AM1/14/18
to
Hi,

I'm writing my own Forth. While building floating point numbers from digits, I'd like it generates an exception if any overflow occurs, instead of wrapping the result.

https://github.com/chengchangwu/rtforth/blob/master/src/parser.rs#L26

But which exception should it generate? I cannot find clear explanation of exceptions in DPANS94.

NN

unread,
Jan 14, 2018, 7:29:19 AM1/14/18
to

ccwu

unread,
Jan 14, 2018, 8:16:43 AM1/14/18
to
NN於 2018年1月14日星期日 UTC+8下午8時29分19秒寫道:
Only one line of explanation for every exception without any examples is not enough. For example, there is no integer overflow exception. Should I use exception -11, result out of range?

Anton Ertl

unread,
Jan 14, 2018, 9:50:17 AM1/14/18
to
ccwu <ccwu6...@gmail.com> writes:
>I'm writing my own Forth. While building floating point numbers from digits, I'd like it generates an exception if any overflow occurs, instead of wrapping the result.

If you are using IEEE FP representation, producing an infinity on
overflow looks like the way to go.

>https://github.com/chengchangwu/rtforth/blob/master/src/parser.rs#L26
>
>But which exception should it generate? I cannot find clear explanation of exceptions in DPANS94.

There is no standard assignment of exception numbers to error
conditions, so you pick what seems appropriate, or introduce a new,
system-specific one. -43, -11, -46, -54, and -55 would appear
fitting, to various degrees. In my programming practice, the only
role the number plays is to determine which error message is produced;
when I test for a specific error after CATCHing, it maybe other people
test for specific throw codes after CATCHing it's a throw code that I
coded into my program (i.e., not a code that the system threw).

- anton
--
M. Anton Ertl http://www.complang.tuwien.ac.at/anton/home.html
comp.lang.forth FAQs: http://www.complang.tuwien.ac.at/forth/faq/toc.html
New standard: http://www.forth200x.org/forth200x.html
EuroForth 2017: http://euro.theforth.net/
0 new messages