AutoHotkey Community

It is currently May 27th, 2012, 1:38 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: ArithmeticError
PostPosted: July 15th, 2005, 8:21 pm 
Offline

Joined: February 14th, 2005, 4:05 pm
Posts: 4710
Location: Boulder, CO
If there is an error evaluating an expression, it could set the ErrorLevel. For example x := 1/0 or y := 1<<64 or z := sqrt(-1).
1 = fix point overflow
2 = floating point overflow
3 = imaginary square root
4 = log of negative number…

The error level need not be a bit mask, because the first error usually prevents a meaningful evaluation of the rest of the expression.

It could be shifted up, starting from say 256, reserving 8 bits for the uppermost user function. Of course a construct like f(g(1/0)) indicates a fix point overflow and the user ErrorLevel of f(), but the error level of g() is lost. For that we could have a cumulative error bit: there was a user set ErrorLevel in the course of evaluating the expression.

Another possibility is to leave ErrorLevel alone, but introduce another built in variable: ArithmeticError. It is set to 0 at start of a thread, but it is set and stays set at an error. This way the user can trust the result of a series of calculations if ArithmeticError is still 0 at the end. Otherwise s/he can reset it to 0 and do corrective actions.


Report this post
Top
 Profile  
Reply with quote  
 Post subject: Re: ArithmeticError
PostPosted: July 16th, 2005, 5:05 pm 
Offline

Joined: March 2nd, 2004, 3:36 pm
Posts: 10720
Laszlo wrote:
Another possibility is to leave ErrorLevel alone, but introduce another built in variable: ArithmeticError. It is set to 0 at start of a thread, but it is set and stays set at an error. This way the user can trust the result of a series of calculations if ArithmeticError is still 0 at the end. Otherwise s/he can reset it to 0 and do corrective actions.
I agree that it's best to leave ErrorLevel alone, mainly because changing it would break existing scripts that rely on the fact that most expressions don't change ErrorLevel.

Your idea for implementation seems good. I've added it to the to-do list.

Thanks.


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: oldbrother and 1 guest


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group