skip to main content

kiesler.at

Boundary Checks with gforth
updated by rck, 2004-05-21

Forth is a fascinating language. I've been hunting a bug in definition of mere 5 words for quite some weeks now. Now that I know, why things are the way the are, it seems quite trivial. I'm documenting the definition of check-range ( u lower-bound upper-bound -- ), while I still know about it.
                     
1 | 2 | 3

The big BUT

So far, so good. This word was defined in the MIPS-Assembler already. So where was my problem? Well, to be honest, the understanding of that function wasn't my primal goal. It didn't work the way I supposed it to! I got the invalid argument error all the time.

what result would you expect from 0 0 0 within .? I'd expect -1, that would be true. But it's 0!!

To get -1, you'd have to check 0 0 1 within .. That's because the check within performs isn't lower <= value <= upper, but lower <= value < upper. The upper-value always has to be one more, than the highest possible value.

Conclusion

Programming is for masochists. Especially with forth. On the other hand, it's kind of a cool language, if you have figured it out.

With the right ammount of documentation, problems like this one wouldn't exist. Well, try to search the web for "forth within definition word". You'll get everything but useful results.

                     
1 | 2 | 3



RSSComments - Make a comment
The comments are owned by the poster. We are not responsible for its content.
RSSAll Articles
2008, 2007, 2006, 2005, 2004

What's Related

Link Manager

Forth

Article Manager

Forth

FAQ

Forth

Latest Updates

AdministrativeTexts
updated by freddiemac1993, 2013-06-14
wiki

Re: adventures
created by brittdavis10, 2012-02-23 (1 rply, 3 views)
thread

Re: how to run phpwebsite...
created by alexander, 2011-08-25 (2 rpls, 3607 views)
thread

Re: Forum tags
created by HaroldFaragher, 2011-08-22 (3 rpls, 8488 views)
thread


Zu den KO2100 Foren