• A generalisation of CREATE DOES>

    From albert@albert@spenarnc.xs4all.nl to comp.lang.forth on Mon Apr 1 14:42:10 2024
    From Newsgroup: comp.lang.forth

    Consider:

    : object1 CREATE , DOES> @ ;
    (object1 is CONSTANT)
    12 object1 twelve
    twelve .

    I transform this to
    ( _ is a don't care value )
    _ class mystruct1 \ mystruct1 is the class name
    M: field1 @ M; , \ field1 is a method/field
    endclass

    12 mystruct1 twelve \ Make `twelve the current `mystruct1 object.

    twelve \ Make twelve current
    field1 .
    12 OK

    Now class can be generalized with more fields, where
    CREATE DOES> is notamenable to this.
    The does> action works on the offset currently commanded by
    `` , ALLOT 2, '' and similar actions.

    _ _ class mystruct2 \ mystruct2 is the class name
    M: field1 @ M; ,
    M: field2 @ M; ,
    endclass

    12 11 mystruct2 eleven+ \ eleven+ is the object.

    eleven+ \ Make eleven+ current
    field1 .
    11 OK
    field2 .
    12 OK

    More action are possible with the same offset:
    _ class mystruct2 \ mystruct2 is the class name
    M: field1 @ M;
    ( par ) ,
    M: field! ! M;
    M: field@ @ M;
    0 ,
    endclass

    This is a one screen oo.
    [That is a bit dishonest. It pulls in the one screen formatting. ]

    The whole tmanx (musical instrument control) is written using this
    simple oo.
    The reverse engineering assembler uses this too, but there the case
    can be made for inheritance. However it works, manages to deconstruct
    a 64 bit Forth and assembles to the exact same code.

    Groetjes Albert
    --
    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 -
    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From minforth@minforth@gmx.net (minforth) to comp.lang.forth on Mon Apr 1 14:08:52 2024
    From Newsgroup: comp.lang.forth

    This reminds me of Dick Pountains book Object-Oriented Forth.
    What makes your own CREATE DOES> extension special?

    BTW for those who are interested or out of pure nostalgia,
    Pountain's book is freely available: https://dn790008.ca.archive.org/0/items/object-oriented-forth-implementation-of-data-structures-by-pountain-dick-z-lib.org/Object-oriented%20forth%20%20Implementation%20of%20data%20structures%20by%20Pountain%2C%20Dick%20%28z-lib.org%29.pdf
    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From albert@albert@spenarnc.xs4all.nl to comp.lang.forth on Wed Apr 3 10:04:29 2024
    From Newsgroup: comp.lang.forth

    In article <3bae9cb4768fcdda16789595e307dcdf@www.novabbs.com>,
    minforth <minforth@gmx.net> wrote:
    This reminds me of Dick Pountains book Object-Oriented Forth.
    What makes your own CREATE DOES> extension special?

    The simplicity and the relation to CREATE DOES>.


    BTW for those who are interested or out of pure nostalgia,
    Pountain's book is freely available: >https://dn790008.ca.archive.org/0/items/object-oriented-forth-implementation-of-data-structures-by-pountain-dick-z-lib.org/Object-oriented%20forth%20%20Implementation%20of%20data%20structures%20by%20Pountain%2C%20Dick%20%28z-lib.org%29.pdf

    I have a fotocopie, and read it once. This is an academic, "me too"
    exercise and I'm not aware that any one has used it to good results.
    Compare this to mine. Or Bernd Paysan mini-oof that are actually
    used for his gui.

    Groetjes Albert
    --
    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 -
    --- Synchronet 3.20a-Linux NewsLink 1.114