[comp.lang.forth] Forth access to external procedures

wmb@ENG.SUN.COM (Mitch Bradley) (04/15/91)

> > I have a fair amount of experience in this area;  I have developed >"call
> > compilers" to allow Forth to call external routines for about a >dozen

> Mitch,
>
> I've been experimenting with external calls on DOS machines. Intuitively it
> seems like this ought to be easy.  But the format of the DOS object code
> completely escapes me.  I beleive that this is one of the reason that windows
> created the new DLL format.  Although I can't find out what that is.
>
> Have you had any success using DOS?
>
> Gene

One of the most difficult problems with linking Forth to externally-generated
procedures is the fact that most popular low-end machines (PC, Mac, Atari)
have no single "standard" software development environment.  With Unix systems
like Sun workstations, you can count on there being a "preferred" software
development environment, with a well-known single linker/object file format.

The PC world has several competing development environments, and their
object file formats are not necessarily compatible.

I haven't solved the dynamic linking problem in the PC environment (in fact,
I haven't really tried; the PC Forth marketplace is crowded, and I don't
choose to devote my development resources to that market).  I have solved
the static linking problem with my C Forth 83 product, which happens to
run on PCs.  The key is to let the C compiler take care of it.  C Forth 83
lets you add entries to the C switch statement at the core of the Forth
kernel, and those new entries can call externally-supplied subroutines.
You just let the C linker worry about the object file formats.

The advertisements for HS Forth claim that it allows pretty general
cross-language linkage, and I expect that LMI has something along those
lines too, at least with their "compiled to object code" Forth product
that is based on Tom Almy's work.

Mitch