Google Groups Home
Help | Sign in
Message from discussion strongForth 1.1 with floating-point word set
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
Stephan Becher  
View profile
 More options Nov 11 2006, 2:18 am
Newsgroups: comp.lang.forth
From: "Stephan Becher" <stephan.remove-this.bec...@t-online.de>
Date: Sat, 11 Nov 2006 08:18:45 +0100
Local: Sat, Nov 11 2006 2:18 am
Subject: strongForth 1.1 with floating-point word set
Version 1.1 of strongForth is now available at
http://home.vrweb.de/~stephan.becher/forth/.

StrongForth supports strong static type checking and extensively uses
operator overloading, which makes it a non-standard system. For example,
words whose stack effect cannot be determined at compile time, like ?DUP,
are not available. Since the interpreter and the compiler are aware of the
data types, many words can be overloaded. For example, overloaded versions
of + replace +, D+, M+ and F+. Every definition has an unambiguous stack
effect that is stored in the header. However, care has been taken to make
strongForth as close to ANS as possible.

The most important addition in version 1.1 is the floating-point word set.
The floating-point word set actually demonstrates a number of unique
features of strong static type checking. Most floating-point words do not
need the prefix "F" in their name. F+ becomes +, FCONSTANT becomes CONSTANT
and FSWAP becomes SWAP. Stack movement words like DUP, DROP, SWAP, OVER and
ROT are overloaded to work on any combination of data types.:

1234 TRUE 1000000. 3.1415926536E0 ROT . . SWAP . .
TRUE 3.1415926536 1234 1000000  OK

(Of course, . is heavily overloaded as well.) If you want to swap two data
items, you simple write SWAP without considering the size of the operands.
In ANS Forth, you have to write ROT or ROT ROT in order to swap a cell and a
double cell. This works fine, but is definitely not intuitive and can impact
readability. Swapping cells or double cells with floating-point numbers is
not possible in ANS Forth, but in strongForth it's no problem.

This raises the question whether strongForth uses the unique or the separate
floating-point stack model. And the answer is: Both. Floating-point numbers
are kept on the separate hardware floating-point stack, but the programming
model is the same as for a unique stack. This is possible, because the data
type of each stack item is known at compile time.

Data typing also allows a much more sophisticated usage of Forth as a
scripting language. For example, a word like

SET-VOLTAGE ( FLOAT -- )

works as expected when provided with a floating-point operand, but is
rejected when you accidentally provide it with an integer. Unless you define
an overloaded version that accepts an integer. Thus, serious mistakes are
less likely.

StrongForth is a 16-bit text-mode application that runs in the DOS-box of
every Windows PC. In order to allow ports to other environments, I finally
decided to make it available under the GNU General Public License.

Regards,
Stephan


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2008 Google