• History of CREATE...DOES> ?

    From Anton Ertl@21:1/5 to All on Thu Jul 25 12:17:25 2024
    fig-Forth has <BUILDS...DOES> (and the associated implementation with
    an extra cell that points to the threaded code behind DOES>).
    Forth-79 standarizes CREATE...DOES>; and a popular implementation of
    that is to trampoline through the place behind DOES> to the actual
    code address. Where did that implementation and CREATE..DOES> in
    general come from?

    My guess is that it did not come from Forth, Inc.: At the time of
    Forth-79 AFAIK Forth, Inc.'s Forths were miniForth and microForth.
    And given that fig-Forth started out as a port of microForth to the
    6502, I doubt that Forth, Inc. used CREATE..DOES>. Also, Forth,
    Inc. ignored Forth-79 (IIRC Elizabeth Rather described it as
    inconsistent or some other statement that she would not have made if
    Forth, Inc. had actually accepted and implemented Forth-79).

    At least dxf is very well versed in historic Forth developments.
    Maybe he or somebody else can answer my question: Where did the
    implementation described above and CREATE..DOES> in general come from?

    - anton
    --
    M. Anton Ertl http://www.complang.tuwien.ac.at/anton/home.html
    comp.lang.forth FAQs: http://www.complang.tuwien.ac.at/forth/faq/toc.html
    New standard: https://forth-standard.org/
    EuroForth 2024: https://euro.theforth.net

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Anton Ertl@21:1/5 to dxf on Fri Jul 26 07:13:03 2024
    dxf <dxforth@gmail.com> writes:
    There's a detailed description of the origins of these in Chuck's
    address "FORTH: The Last Ten Years ..." (FD V1N6. p72).

    Thanks. So Forth, Inc. did have CREATE..DOES> by 1980 (when this
    article was published). My family tree says about polyForth:

    \I FORTH, Inc.'s PC offering
    \U http://www.forth.com/resources/evolution/evolve_3.html#3.2
    1982 Implementation polyFORTH
    miniFORTH begot polyFORTH \ FORTH, Inc., approx. 1980

    Not sure where I have the 1982 and 1980 numbers from. According to
    "The Evolution of Forth", the first edition of Starting Forth (1981)
    was mostly written for polyForth, so the 1980 number looks more
    plausible now.

    So maybe this new CREATE..DOES> first appeared in polyForth, or maybe
    in later versions of miniForth.

    But CREATE...DOES> also made it into Forth-79, so it must have been
    more widespread by then. In particular, Chuck Moore's description in
    the article above does not seem clear enough to me for developing
    something compatible independently, if you start with fig-Forth (where
    CREATE was best fit as a factor of CODE, not VARIABLE). Of course,
    once you know how CREATE and DOES> are defined in Forth-79, working
    out an implementation is not that difficult, but how come they were
    defined in Forth-79 in that way?

    They all came from Forth Inc but mostly not Chuck. He needed help!

    I am not sure whether he needed it, but he certainly got it. The name
    I read again and again is Dean Sanderson, wo seems to have had quite a
    lot of influence on the evolution of Forth.

    There is an ariticle about RISC-V which identifies what instruction
    comes from where. As a complement to the family tree, it would be
    great if someone documented the history of certain words and features
    of Forth. But who would do that?

    BTW, my family tree contains Elizabeth Rather's verdict about
    Forth-79:

    \ from Elizabeth Rather
    \ As far as standards conformance is concerned, Forth-79 was such an
    \ incomplete and contradictory "standard" that I doubt anyone can fully claim \ conformance to it. polyFORTH was very close to Forth-83, and had an
    \ optional compatibility suite for the non-conforming bits. This unhappy
    \ state of affairs came about because Forth-83 was done in two meetings; the
    \ design of pF was finalized between the first and second, and conformed to
    \ all the "firm decisions" taken in the first meeting. But some of those were \ reversed in the 2nd meeting, and that created too many incompatibilities for \ us to follow. SwiftForth conforms to ANS Forth.

    Ok, that explains the 1982 date given above. But OTOH Elizabeth
    Rather was a co-author of "The Evolution of Forth", which claims that
    Starting Forth was mostly written for polyForth.

    I see in https://www.computerhistory.org/collections/catalog/102640347
    that the "polyForth II -- Reference manual" is from 1982, so maybe
    that explains it: polyForth in 1980, polyForth II compatible with the
    first draft of Forth-83 from 1982.

    In any case, the question remains how CREATE..DOES> came into
    Forth-79.

    - anton
    --
    M. Anton Ertl http://www.complang.tuwien.ac.at/anton/home.html
    comp.lang.forth FAQs: http://www.complang.tuwien.ac.at/forth/faq/toc.html
    New standard: https://forth-standard.org/
    EuroForth 2024: https://euro.theforth.net

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From albert@spenarnc.xs4all.nl@21:1/5 to Anton Ertl on Fri Jul 26 13:56:51 2024
    In article <2024Jul25.141725@mips.complang.tuwien.ac.at>,
    Anton Ertl <anton@mips.complang.tuwien.ac.at> wrote:
    fig-Forth has <BUILDS...DOES> (and the associated implementation with
    an extra cell that points to the threaded code behind DOES>).
    Forth-79 standarizes CREATE...DOES>; and a popular implementation of
    that is to trampoline through the place behind DOES> to the actual
    code address. Where did that implementation and CREATE..DOES> in
    general come from?

    In 2000 I wanted to create a simple Forth in fig-Forth vein,
    in fact merely an iso-fication of fig-Forth.
    In 1993 for the transputer Forth, I proposed to get rid of
    NAME>XT XT>BODY LINK>NAME FORGET>LINK ,what have you, and coined the "dea" concept that is a token/address/handle to access all the properties
    of a word. All words that handle a "word" now uses its dea, and obviously
    the dea can serve as an execution token in the sense of iso.
    No longer is replacing the execution token behaviour
    affecting the identity of a word. No longer is it a problem
    if a word has no name. You can unlink a word from its wordlist
    and link it elsewhere. Etc.

    I arrived at uniform cell wide fields with names
    CFA DFA FFA LFA NFA [SFA] [XFA]
    CFA pointer to executable code
    DFA pointer to DATA
    FFA flags
    LFA pointer to next dea
    NFA pointer to a non-brain-damaged string, i.e. one cell count + chars.
    [ options SFA pointer to source code ]
    [ XFA optional experimental extra pointer ]

    Now it became clear that the iso-requirements of CREATE demand that a
    CREATEd words have two part in the DATA field: a pointer to high
    level code and the body in the ISO sense. Both fields are modifiable.
    Ting came to a similar conclusion implementing a Forth in a c-type
    oo language (I remember Java) for a need to two separate fields.

    So it is a natural idea following from iso-demands, but maybe
    hold back with implementation tricks. Notably a CALL to a the common
    code with this CREATE class, immediately followed by the data,
    because a pointer to this would be pushed on the stack, saving
    an instruction and one byte. Forth has no problems with spaghetti
    code, but spaghetti data is equally bad.
    The entanglement of the data and code fields in this way,
    may no longer advantageous for modern processors.
    Moreover the 56 bytes a Forth header takes is no longer a
    consideration with Gbyte memories.


    My guess is that it did not come from Forth, Inc.: At the time of
    Forth-79 AFAIK Forth, Inc.'s Forths were miniForth and microForth.
    And given that fig-Forth started out as a port of microForth to the
    6502, I doubt that Forth, Inc. used CREATE..DOES>. Also, Forth,
    Inc. ignored Forth-79 (IIRC Elizabeth Rather described it as
    inconsistent or some other statement that she would not have made if
    Forth, Inc. had actually accepted and implemented Forth-79).

    At least dxf is very well versed in historic Forth developments.
    Maybe he or somebody else can answer my question: Where did the >implementation described above and CREATE..DOES> in general come from?

    It is a direct consequence of ISO. It has been independantly
    invented (if that is the proper word) at least two times by
    TING and me.


    - anton
    --
    Don't praise the day before the evening. One swallow doesn't make spring.
    You must not say "hey" before you have crossed the bridge. Don't sell the
    hide of the bear until you shot it. Better one bird in the hand than ten in
    the air. First gain is a cat purring. - the Wise from Antrim -

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Anton Ertl@21:1/5 to dxf on Thu Aug 1 13:48:46 2024
    dxf <dxforth@gmail.com> writes:
    On 26/07/2024 5:13 pm, Anton Ertl wrote:
    ...
    But CREATE...DOES> also made it into Forth-79, so it must have been
    more widespread by then.

    Not necessarily. What systems had 'multiple WHILE' before ANS introduced
    it?

    cmForth <https://raw.githubusercontent.com/ForthHub/cmFORTH/combined/cmforth.fth>:

    : WHILE ( a - a a) \ IF SWAP ;
    : REPEAT ( a a) \ AGAIN \ THEN ;

    where "\" is [COMPILE]. AFAIK the SWAP in the WHILE was relatively
    late and while the SWAP was still in REPEAT, you had to implement
    multiple-exit BEGIN loops differently, but up until fig-Forth (where
    "compiler security" was a headline feature) such things were certainly possible. It's interesting that "compiler security" discouraged such
    usage, which made it easier to specify in Forth-94 that the CS-SwAP
    happens in WHILE, not in REPEAT (because there was little existing
    practice for such things at the time).

    Brodie mentions it in 'Thinking FORTH' (1984) but without details or >endorsement by a Standard who would risk it?

    Apparently not that many, or they had switched to the newer WHILE
    already, otherwise standardizing it in Forth-94 would not have flown.


    --
    M. Anton Ertl http://www.complang.tuwien.ac.at/anton/home.html
    comp.lang.forth FAQs: http://www.complang.tuwien.ac.at/forth/faq/toc.html
    New standard: https://forth-standard.org/
    EuroForth 2024: https://euro.theforth.net

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)