Simple Forth written in C

1274 views
Skip to first unread message

Bill Sturm

unread,
Dec 17, 2000, 5:07:13 PM12/17/00
to
Can anyone suggest a very simple Forth language that is written in
portable C. Just to be able to create and execute dictionary words is
all that I need. A core group of words written in C would probably be
necessary. Speed is less important to me than simplicity.

Bill Sturm

cLIeNUX user

unread,
Dec 18, 2000, 1:55:34 AM12/18/00
to
bst...@gatecom.com...

The original Forth-in-C is on gatekeeper.dec.com. Circa 1982 I
think. Probably on taygeta somewhere also. Probably
the simplest. PFE isn't to bad either. < --emacs-remark-elide >.
Then there's the 1992 IOCC winner with 12 words. Rather a minimal
Forth. International Obfuscated C contest. That one is about 1200
bytes of code I think.

Rick Hohensee
Forth, unix, everything is a device

Julian V. Noble

unread,
Dec 18, 2000, 10:42:29 PM12/18/00
to
Norm Smith wrote a book, "Write Your Own Programming Language in C++".
His example was Until, a Forth variant. Many people use it or something
like it as a script language within C programs. Look on

www.taygeta.com

J.V. Noble

Jeffrey R. Fox

unread,
Dec 20, 2000, 6:22:01 PM12/20/00
to
Bill:

Phil Burk's pForth (http://www.softsynth.com/pforth/) is my choice -- I have
used this system extensively under Solaris and Window/Extended DOS and even
compiled it under OpenVMS. It is a 32-bit ANSI-C source ANS compatible Forth. I
use it often to test C++ classes -- it is one of the few systems that will
compile cleanly with the C++ compilers. It has the simplest design in comparison
with Baden's ThisForth, GForth, ATLAST, Until, and PFE. It isn't anywhere near
as fast as GForth, but there you must be compiling under GCC, and I still
haven't been able to figure out how to get new C defs into it. If you are going
to be without complete documentation, this is the choice. My interests are in
portablility and mixed-language programming.

ThisForth also works very well, and while it uses the macro expander M4 to get
from pseudo-Forth to C source before compilation, the true Forther might prefer
that. Will Baden knows his Forth, and it has a wealth of macro features that are
a gas. GForth will eventually be documented, and it uses something similar,
though built-in, to do the translation. In PFE, the Forth words are just
implemented as C functions, so that isn't hard either.

Jeffrey Fox, Worldcom

P.S. for good old DOS, I use ThisForth or I put the C/C++ in an interrupt
callable TSR. If you want to mix C/C++ w/Forth under Windows, you can always put
the C/C++ in a DLL and then call it from a native Forth like Win32Forth or the
commercial SwiftForth (Forth, Inc.). The later costs money, but hey, you get a
book, and boy is it fast. You can even make a Forth DLL so that your C/C++
mainline can call Forth.

P.P.S. Mitch Bradley (Bradley Forthware) used to sell a system w/source called
C-Forth. I bought one of those, and always thought it was pretty good -- it fit
well with Solaris, and I used it under DOS also.

P.P.P.S. Hey and if you want to substitute Java for C/C++, then take a look at
FIJI, HolonJ, JEForth, etc. FIJI is a lot of fun, and HolonJ (shareware) is a
complete programming environment.

P.P.P.P.S send me an email if you can't find one of these at www.forth.org.

Jeffrey R. Fox

unread,
Dec 20, 2000, 6:17:30 PM12/20/00
to
Bill:

Phil Burk's pForth (http://www.softsynth.com/pforth/) is my choice -- I have
used this system extensively under Solaris and Window/Extended DOS and even
compiled it under OpenVMS. It is a 32-bit ANSI-C source ANS compatible Forth. I
use it often to test C++ classes -- it is one of the few systems that will
compile cleanly with the C++ compilers. It has the simplest design in comparison
with Baden's ThisForth, GForth, ATLAST, Until, and PFE. It isn't anywhere near
as fast as GForth, but there you must be compiling under GCC, and I still
haven't been able to figure out how to get new C defs into it. If you are going
to be without complete documentation, this is the choice. My interests are in

portability and mixed language programming.

ThisForth also works very well, and while it uses the macro expander M4 to get
from pseudo-Forth to C source before compilation, the true Forther might prefer
that. Will Baden knows his Forth, and it has a wealth of macro features that are
a gas. GForth will eventually be documented, and it uses something similar,
though built-in, to do the translation. In PFE, the Forth words are just
implemented as C functions, so that isn't hard either.

Jeffrey Fox, Worldcom

P.S. for good old DOS, I use ThisForth or I put the C/C++ in an interrupt
callable TSR. If you want to mix C/C++ w/Forth under Windows, you can always put
the C/C++ in a DLL and then call it from a native Forth like Win32Forth or the
commercial SwiftForth (Forth, Inc.). The later costs money, but hey, you get a
book, and boy is it fast. You can even make a Forth DLL so that your C/C++
mainline can call Forth.

P.P.S. Mitch Bradley (Bradley Forthware) used to sell a system w/source called
C-Forth. I bought one of those, and always thought it was pretty good -- it fit
well with Solaris, and I used it under DOS also.

P.P.P.S. Hey and if you want to substitute Java for C/C++, then take a look at
FIJI, HolonJ, JEForth, etc. FIJI is a lot of fun, and HolonJ (shareware) is a
complete programming environment.

P.P.P.P.S send me an email if you can't find one of these at www.forth.org.

Jeffrey R. Fox

unread,
Dec 20, 2000, 7:35:52 PM12/20/00
to
Bill:

Jeffrey Fox, Worldcom

Bill Sturm

unread,
Dec 20, 2000, 8:04:51 PM12/20/00
to
On Mon, 18 Dec 2000 06:55:34 -0000, r@your_host.com (cLIeNUX user)
wrote:

>The original Forth-in-C is on gatekeeper.dec.com. Circa 1982 I
>think. Probably on taygeta somewhere also. Probably
>the simplest.

I cannot seem to find it. Can you tell me which directories to look
in.

Bill

Bill Sturm

unread,
Dec 20, 2000, 8:08:29 PM12/20/00
to
On Wed, 20 Dec 2000 23:17:30 GMT, "Jeffrey R. Fox"
<Jeffr...@wcom.com> wrote:

>Bill:
>
>Phil Burk's pForth (http://www.softsynth.com/pforth/) is my choice -- I have
>used this system extensively under Solaris and Window/Extended DOS and even
>compiled it under OpenVMS. It is a 32-bit ANSI-C source ANS compatible Forth.

Other have mentioned pForth, I downloaded it and it looks very useful
for a PC.

I forget to mention, but the reason that I wanted ANSI C was to port
to a Z-World or Rabbit board under Dynamic C. I was hoping for a very
small and simple version that would be easy to port to an 8 bitter.

Thanks,

Bill


cLIeNUX user

unread,
Dec 20, 2000, 11:18:24 PM12/20/00
to
bst...@gatecom.com...
>On Mon, 18 Dec 2000 06:55:34 -0000, r@your_host.com (cLIeNUX user)
>wrote:
>>The original Forth-in-C is on gatekeeper.dec.com. Circa 1982 I
>>think. Probably on taygeta somewhere also. Probably

1985 it seems. When it made it to gatekeeper is another matter.

>>the simplest.
>
>I cannot seem to find it. Can you tell me which directories to look
>in.
>
>Bill

Did you find the IOCC one? It's a gem.

Mmmmm. gatekeeper is an archive in the perjorative sense. Things are hard
to find. If I have that Forth locally I'll let you know....

(rummagerummagerummage)

I have a cforth/ that seems to have come from a cforthu.arc, which has a
forth.doc with this in it......

....................................................................
C-FORTH: a portable, C-coded figFORTH interpreter.

Written by Allan Pratt; completed April 1985.

This is a FORTH interpreter written entirely in portable C and FORTH. It
requires nothing more than a decent C compiler to use. It is not exactly
fast or efficient, but it is a true FORTH interpreter.

The features include:

Bootstrapping threaded definitions from a near-FORTH dictionary file.
Block file I/O.
Execution tracing and single-stepping.
Breakpoint detection, dumping the stack at the breakpoint.
Saving and automatic restoration of the FORTH environment.
Ability to convert the block file to a line-editor-compatible file, and
back.

Included with the interpreter is a block file containing:

An UNTHREAD utility.
A screen editor with key-binding and cursor-addressing.

BRINGING UP THE INTERPRETER:

THIS FORTH MODEL REQUIRES "int"s TO BE TWICE THE SIZE OF "short"s,
and "short"s to be 16 bits. I realize this is a barrier to portability,
but you can change occurrances of "int" to "long" and "short" to "int" if
"long"s are twice the size of "int"s.
......................................................................

More hints/clues...
It's a 3-part gatekeeper shar archive.
cforthu.arc is 60928 bytes. In that, prims.c is 11k.

Give it the old college try, and if you don't nail it down I can post the
whole thing.

Rick Hohensee
Forth, unix, eggnog latte'

Jeffrey R. Fox

unread,
Dec 21, 2000, 12:47:09 PM12/21/00
to
Bill:

Phil Burk's pForth (http://www.softsynth.com/pforth/) is my choice -- I have
used this system extensively under Solaris and Window/Extended DOS and even

Jeffrey Fox, Worldcom

SLAPINSKAS

unread,
Dec 30, 2000, 2:10:45 AM12/30/00
to
Here possibly at this link?

http://ftp.digital.com/cgi-bin/grep-index?forth

The files there include;
01/12/1986 15k /pub/usenet/comp.sources.unix/volume1/cforth/part1.Z
01/12/1986 29k /pub/usenet/comp.sources.unix/volume1/cforth/part2.Z
01/12/1986 22k /pub/usenet/comp.sources.unix/volume1/cforth/part3.Z

Reply all
Reply to author
Forward
0 new messages