#

## phimvt@lurac.latrobe.edu.au — 2000-08-21 03:37:25

    In my "Comments 4" (18-JUL-00) I asked for a comparison of the languages

    that had been duscussed in the group. W. Tanksley (21-JUL-00) gave a long

    reply (thanks Billy). Since then I have looked at some of the Forth lite-

    rature - we don't have much at our library, though. I express some of my

    thought as follows.

    Forth is a masterpiece. I say this without reservation, and in spite of

    the obvious and sometimes justified criticisms. It is a broad spectrum

    language, from very low level to at least middle level. The low level

    makes it possible to write stand alone programs serving as their own

    operating system. The middle level has been used to squeeze performance

    out of minimal hardware. Some extensions approach the high level of

    the more familiar mainstream languages (see 5. below).

    Forth and Joy both use postfix notation to manipulate a stack. This

    invites further comparisons, and raises the hope that they could profit

    from in ech other in ways that are _specific_ (emphasise SPECIFIC)

    to the two languages and not to others. I feel forced to conclude

    that this view is mistaken. Let me explain.

    1. Access to low level primitives. Forth excels in this. Any high

    level language can be extended to provide this. The Joy prototype

    is written in C, and it would be easy to allow it to access any or

    all of the low level features of C.

    2. Access to its own internal working, in particular access to addresses.

    Of course Forth provides this. So do C and some extensions of

    Pascal. The Lisps, Prolog, ML and Haskell do not, as far as I know.

    This is because it is against their aim: to provide a portable

    programmable high level machine that is independent of its implemen-

    tation. The same holds for Joy.

    3. Assignable variables. Forth and other mainstream languages have it,

    and so do the impure (= non-functional) parts of the Lisps and ML,

    whereas Prolog, Haskell (and Joy) have resisted it.

    4. Manipulating the symbol table. This is quite different

    from 2. and deserves separate discussion. Forth can treat the symbol

    table like any other data structure. No other language does it to the

    same extent. But many have some kind of "undefine", or have seperate

    compilation of different parts to access different libraries, or they

    have partial or full block structure, or modules, abstract data struc-

    tures, record fields, WITH statements and other ways of bringing different

    parts of the symbol table into effect.

    5. The "CREATE(BUILD)..DOES.." duo. This is an immensely powerful

    feature, and as far as I can tell no other language has anything like

    it (CLOS might be an exception - does anyone know?). I suspect it

    cannot be fully emulated by a macro preprocessor. D. Pountain (1987,

    _Object Orianted Forth_) defines second order words in which the

    DOES-part contains the same construct again. He uses the method to

    implement records, abstract data types and lists, including garbage

    collection (useful for a Joy-in-Forth).

    Points 1..5 are of course incomplete and superficial. But they do

    suggest that whatever cross-fertilisation there might be between

    Forth and Joy it will not be due to the common postfix notation.

    Certainly postfix (and prefix) notation lend themselves to a useful

    algebra, all the more if there is no lambda abstraction and hence

    no named formal parameters. If Forth has anything to learn from Joy

    it is not in the language itself but in the metatheory - but for all

    I know a discussion might be lurking in the literature already. Does

    anybody know? In the reverse direction, and independent of postfix

    notation, here are some projects:

    a) In my library I have a Joy-in-Joy interpreter which is very similar

    to the familiar Lisp-in-Lisp interpreter. Neither handles definitions,

    whereas the outer Forth interpreter does. (Comment: The word "interpreter"

    unfortunately means very different things. The two interpreters

    of Forth do not do what Lisp-in-Lisp or Joy-in-Joy do.) Project:

    Is it useful to write an "outer Joy interpreter" in Joy? To be

    useful  his might require additions as in 2. above.

    b) Examine the desirability of adding "CREATE..DOES.." to Joy.

    This might be in tandem with a) or quite independently.

    c) Investigate the power of macros. For text macros a useful starting

    point would be the unix macro preprocessor m4. For syntax macros

    (in Joy itself) some extensions (presumably 2.) are likely to be

    necessary.

    Any comments would be much appreciated.

        Manfred