> Forth, if I understand it rightly, is not tagged (an
> advantage for systems applications) and not garbage collected.
It can't be tagged, since it is a single data type language (like BCPL),
and as you say, it is not GCed.
> Moreover with a language that supports in-lining [like C++ (not my
> favourite by the way) or Haskell say] a big win is possible, since a
> small function may inline in less space than its call takes, and is of
> course faster. This is directly opposed to threaded-code, where by
> definition the small function -must- be called, since it may be
> redefined. Typically threaded code is useful for -debugging- but it is
> best converted into an unthreaded form for use in a module like a
> mailer where it will be normally used unchanged.
Actually this isn't true of Forth - although a service function can be
redefined, the old version is used by any client functions compiled
before the change. There have been experimental systems which do allow
redefinition, but the overheads aren't considered worthwhile in the
embedded systems market which Forth mainly addresses now. Some modern
Forths do have limited automatic inlining, and more usefully there are
rough analogues of C++'s "inline" keyword that can be used to imbed
sequences of instructions in the word currently being defined.
> The only snag here is that assembler is non-portable. The
> C-interface of POPLOG is to my mind preferable.
Horses for courses, surely. Barring the odd fanatic (and some of them
can be *very* odd) Forth is used for imbedded systems - very machine
specific, and C needs libraries for some things that assembler can do
directly (e.g. accessing I/O ports on a non memory-mapped machine).
The C interface for Poplog is more useful for interfacing X etc:
no-one will use Pop to run a washing machine, after all.
Incidentally, since I doubt it will get a mention otherwise in a
mainly Unix/VMS forum, it may be worth mentioning that the structured
BASIC supplied with MS/DOS 5 and up is a threaded compiler: individual
lines are compiled (as the editor cursor leaves the line), and are
used by something analogous to the "inner interpreter" of early
Forths. The main advantages in this case are immediate syntax
checking, and the ability to resume the program after most edits. A
matching true compiler is available for the finished version.
Scott
|