• Lispification of Forth

    From albert@spenarnc.xs4all.nl@21:1/5 to All on Tue May 27 13:11:01 2025
    Lispification of Forth means that all parts of Forth are dynamically
    allocated. This means that all parts can be changed independantly,
    headers, names high and low level code, without affecting the whole.
    Once this is accomplished you want to expand the header with a source field. This contains a heavily commented source of this word.
    Now you can edit the source, and compile it to replace the code,
    lispy and risky.

    Of course you cannot lengthen any data item without dynamic
    allocation.
    This leans heavily on the circular allocation
    wordlist facility. Any free space can be configured as a heap.
    Also this wordset has SIZE, such that a single address determines
    a string.

    You need sufficient heap space, reserve a 1 Gbyte file for this.
    (However you could easily expand it later.)
    Use memmap() to map this in a fixed location in Forth, not
    conflicting with the memory map. Now this space can be
    configured for a heap. For each step you must close
    and consolidate those heap file. Then you can continue
    where you left off, for next steps.

    The strategy sketched here can work with a simple Forth like
    ciforth. An important notion is that most space can be
    considered to be belonging to a certain dictionary entry,
    and floating buffers are rare. They all require special care
    to a possible point that this approach may be impractical
    for e.g. gforth. In particular if you have
    interspersed calling high level code with machine code,
    you can sit on the roof.

    Steps
    1. replace all
    where you need the name of a word, e.g. in ciforth:
    `` >NFA @ $@ '' by _N@
    where you need the length a word, e.g. in ciforth:
    `` >NFA @ $@ '' by _L@
    in all code.
    This can be a patch, i.e. in place replacing @ and $@ by NOOP.
    2. Make a word that replaces all namefields by ALLOCATEd names.
    Execute and patch the code for _N@ _L@
    : _N@ DUP SIZE ;
    : _L@ SIZE ;
    SIZE is a facility of a sensible ALLOCATE wordset.
    2a test: change the name of DROP with a Chinese word.
    Check compilation and other proper working.
    3. ALLOCATE the code for docol docon dovar dodoes
    3-I
    For each high level code word :
    patch the CFA appropriately
    ALLOCATE and patch the DFA
    3a run the total test
    4. For each low level code word :
    ALLOCATE and patch the CFA
    4a run the total test
    5. For each storage word :
    patch the CFA
    ALLOCATE the buffer, if any, and patch the DFA
    5a run the total test
    6. For each word:
    ALLOCATE the header
    patch the pointer to this word in each high level code
    Now the whole Forth is transported and the previous held
    space could be erased.
    7 you don't need HERE anymore, everything can be allocated.
    Eliminate HERE PAD and transform <#
    8 Hang the task dependant buffers (terminal-input-buffer, return stack,
    data stack, user space) off COLD.
    9 Fill in the source field of words with the actual code.

    10 add an editor to edit the source field and a single word recompile.

    11 now test , by redefining drop with a different code sequence.

    Now the Forth is totally dynamic. E.g you can eliminate words
    that are not used, and recover the memory.
    You can transform the Forth to whatever.
    Thus is a substrate of a computer intelligence.

    It is wise to use rings of protection. The inner ring must
    be modified with great care or the computer intelligence can
    die. She herself may be allowed to modify the outer rings
    or experiment writing programs that run on the outermost ring.
    --
    Temu exploits Christians: (Disclaimer, only 10 apostles)
    Last Supper Acrylic Suncatcher - 15Cm Round Stained Glass- Style Wall
    Art For Home, Office And Garden Decor - Perfect For Windows, Bars,
    And Gifts For Friends Family And Colleagues.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From mhx@21:1/5 to All on Tue May 27 16:31:59 2025
    Sort of replacing an old-fashioned book index with a search engine
    connected to the internet ...

    But I like the general idea.

    -marcel

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From minforth@21:1/5 to All on Tue May 27 20:23:02 2025
    It might be less complicated to use tokens or hashes
    instead of memory addresses in high-level Forth code.
    All dictionaries, data or VM code sequences could then
    be localised exclusively via a central token table or
    hash table. Replacing/modifying a word would be very
    simple by patching the token/hash table.

    --

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From mhx@21:1/5 to minforth on Wed May 28 05:09:28 2025
    On Tue, 27 May 2025 20:23:02 +0000, minforth wrote:

    It might be less complicated to use tokens or hashes
    instead of memory addresses in high-level Forth code.
    All dictionaries, data or VM code sequences could then
    be localised exclusively via a central token table or
    hash table. Replacing/modifying a word would be very
    simple by patching the token/hash table.

    Not when a word is vectored and/or using ` ' woord , ` and the like.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From minforth@21:1/5 to All on Wed May 28 09:03:11 2025
    Of course you know better. In my fantasy, xt's have no
    relation to physical addresses, only to table slots.

    Therefore words such as ' or , or deferred words can work
    with - let's call them - hashed-xts in the same way as
    with 'normal' xts.

    The inner interpreter, of course, has to resolve the
    hashed-xts in order to retrieve real memory addresses.
    This is a time penalty, but we are not talking about
    speed here, but about great flexibility.

    IIRC in HolonForth it was also possible to access and
    modify code and even sources on the fly, and were
    immediately active after commitment. I don't know how
    Wolf Weijgaard implementd that, perhaps he was once
    inspired by Smalltalk.

    --

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Anton Ertl@21:1/5 to minforth on Wed May 28 09:52:16 2025
    minforth@gmx.net (minforth) writes:
    IIRC in HolonForth it was also possible to access and
    modify code and even sources on the fly, and were
    immediately active after commitment. I don't know how
    Wolf Weijgaard implementd that,

    "We can solve any problem by introducing an extra level of indirection."

    <https://en.wikipedia.org/wiki/Fundamental_theorem_of_software_engineering>

    That would certainly solve this particular problem.

    In any case, when he demonstrated it, it was very impressive.

    perhaps he was once inspired by Smalltalk.

    That's certainly possible. Like Holon, Smalltalk is a system where
    you can browse and edit individual words, and edit them at run-time.

    - 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 2023 proceedings: http://www.euroforth.org/ef23/papers/
    EuroForth 2024 proceedings: http://www.euroforth.org/ef24/papers/

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From albert@spenarnc.xs4all.nl@21:1/5 to mhx on Thu May 29 12:41:52 2025
    In article <f6f37213a3429712a0ec487175a74360@www.novabbs.com>,
    mhx <mhx@iae.nl> wrote:
    On Tue, 27 May 2025 20:23:02 +0000, minforth wrote:

    It might be less complicated to use tokens or hashes
    instead of memory addresses in high-level Forth code.
    All dictionaries, data or VM code sequences could then
    be localised exclusively via a central token table or
    hash table. Replacing/modifying a word would be very
    simple by patching the token/hash table.

    Not when a word is vectored and/or using ` ' woord , ` and the like.

    "less complicated" . My idea is not complicated, but adding
    hash codes is definitively makes absolutely no sense,
    It definitively makes it more complicated.

    And especially not if the very purpose of the execercise is
    to constantly transform each individual field of a dictionary entry,
    to get that dynamic lisp feel, that you can change the editor
    that you are using.

    A typical step after lispification:
    Enhance each dictionary entry with one field:the source field.
    Decompile and store the result as a string in the heap, now let the
    source field point to the string.
    Now there is a 2DROP in the decompilation . I want to replace 2DROP by
    PDROP. It is easy to do that. Replace everywhere in the source fields.
    Replace the name of `2DROP "2DROP" with "PDROP".
    Done. The Forth is transformed.

    Groetjes Albert
    --
    Temu exploits Christians: (Disclaimer, only 10 apostles)
    Last Supper Acrylic Suncatcher - 15Cm Round Stained Glass- Style Wall
    Art For Home, Office And Garden Decor - Perfect For Windows, Bars,
    And Gifts For Friends Family And Colleagues.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From albert@spenarnc.xs4all.nl@21:1/5 to minforth on Thu May 29 12:47:37 2025
    In article <3182ec14697011f4dda6a722e2f95020@www.novabbs.com>,
    minforth <minforth@gmx.net> wrote:
    Of course you know better. In my fantasy, xt's have no
    relation to physical addresses, only to table slots.

    Who is "you"?
    This is usenet. You are supposed to provide context,
    In order to be taken seriously, you must provide context,
    but not to copy the whole thread in a post. Learn
    snipping.


    <SNIP>
    Probably nonsense, but certainly uncomprehensible text deleted.


    --

    Groetjes Albert
    --
    Temu exploits Christians: (Disclaimer, only 10 apostles)
    Last Supper Acrylic Suncatcher - 15Cm Round Stained Glass- Style Wall
    Art For Home, Office And Garden Decor - Perfect For Windows, Bars,
    And Gifts For Friends Family And Colleagues.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Waldek Hebisch@21:1/5 to albert@spenarnc.xs4all.nl on Sun Jun 1 21:34:23 2025
    albert@spenarnc.xs4all.nl wrote:
    Lispification of Forth means that all parts of Forth are dynamically allocated. This means that all parts can be changed independantly,
    headers, names high and low level code, without affecting the whole.
    Once this is accomplished you want to expand the header with a source field. This contains a heavily commented source of this word.
    Now you can edit the source, and compile it to replace the code,
    lispy and risky.

    Of course you cannot lengthen any data item without dynamic
    allocation.
    This leans heavily on the circular allocation
    wordlist facility. Any free space can be configured as a heap.
    Also this wordset has SIZE, such that a single address determines
    a string.

    You need sufficient heap space, reserve a 1 Gbyte file for this.
    (However you could easily expand it later.)
    Use memmap() to map this in a fixed location in Forth, not
    conflicting with the memory map. Now this space can be
    configured for a heap. For each step you must close
    and consolidate those heap file. Then you can continue
    where you left off, for next steps.

    You have rather specific idea here. Note however, that for
    Lisp style redefinition of words (functions) all you need
    is extra indirection say via dictionary (as mentioned in
    another post). So Forth word needs to access other words
    via dictionary entry or some other fixed-address intermediate
    thing. Of course, this gives behaviour incompatible with
    traditional Forth.

    Speaking about Lispification, Lisp does not allow you to
    change name of a symbol. All you can do is to change
    maeaning of symbol, that is change variable/function
    that you obtain by accessing the symbol.

    Also, dynamic allocation can be coupled with manual dealocation.
    But if you want to go in Lisp direction, then it is preferable
    to have garbage collection. Practically garbage collection
    means that you need things like headers before various
    objects to identify things to garbage collector. Usual
    approach uses tagged integers (that is one or more bit in an
    integer serves as tag to distinguish it from pointers).
    There may be other tagged things. This means that usual
    expectations of Forth programs are violated.

    Anyway, real system combining features of Lisp and Forth
    works as follows: dictionary is a fixed size hash table
    at fixed location. Each position in the table points
    to list of possible meanings, that is list of pairs
    (word, meaning). Dictionary lookup works as follows:
    string correspnding to a word is hashed giving position
    in the table, then there is linear search trough list
    of pairs looking for matching word. If matching word is
    found lookup gives corresponding meaning. Meaning may be
    a function which can be executed. Or a special object
    representing variable. At given time a word has single
    meaning, but it can be removed or changed.

    As in Forth a function takes arguments from data stack
    and puts results on the data stack, function takes as many
    arguments as it wants and produces as many results as
    iut wishes. A lot of little details is different than
    in Forth, let me just say that return stack is entirely
    managed by the implementation. There is garbage collector
    which in principle can collect almost anything: words,
    variables, functions, various pieces of data. In practice
    there are system objects especially functions that are
    allocated at fixed addresses and not subject to garbage
    collection. Garbage collector itself is a system
    function so will be never garbage collected. However
    it seems that only dictionary is fundamental, the
    rest is mostly for efficiency: on x86_64 system objects
    are reachable via 32-bit addresses and are at fixed
    locations which allows more efficient function calls.
    User objects are moved around in memory needing extra
    indirection and full 64-bit addreses.

    Named functions are accessed via variable objects, calls
    go via corresponding object, re-definition changes
    pointer to actual procedure, so after redefiniton calls
    end up execution new code.

    To summarize: if you really want Lisp features, you are likely
    to get rater different system than Forth.

    BTW: I am not sure what 1 GB is supposed to mean? Do you need
    that much to rebuild ciforth with your changes? FYI, the system
    I outlined above is extremaly bloated by Forth standards, but
    runs happily in few MB. Recompilation needs more memory, but
    currently main "memory eater" is C compilation of few support
    files.

    --
    Waldek Hebisch

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From albert@spenarnc.xs4all.nl@21:1/5 to Waldek Hebisch on Mon Jun 2 12:51:47 2025
    In article <101ih0t$34u04$1@paganini.bofh.team>,
    Waldek Hebisch <antispam@fricas.org> wrote:
    albert@spenarnc.xs4all.nl wrote:
    Lispification of Forth means that all parts of Forth are dynamically
    allocated. This means that all parts can be changed independantly,
    headers, names high and low level code, without affecting the whole.
    Once this is accomplished you want to expand the header with a source field. >> This contains a heavily commented source of this word.
    Now you can edit the source, and compile it to replace the code,
    lispy and risky.

    Of course you cannot lengthen any data item without dynamic
    allocation.
    This leans heavily on the circular allocation
    wordlist facility. Any free space can be configured as a heap.
    Also this wordset has SIZE, such that a single address determines
    a string.

    You need sufficient heap space, reserve a 1 Gbyte file for this.
    (However you could easily expand it later.)
    Use memmap() to map this in a fixed location in Forth, not
    conflicting with the memory map. Now this space can be
    configured for a heap. For each step you must close
    and consolidate those heap file. Then you can continue
    where you left off, for next steps.

    You have rather specific idea here. Note however, that for
    <SNIP>

    To summarize: if you really want Lisp features, you are likely
    to get rater different system than Forth.

    Yes. It is supposed to more powerful than a mere lisp.
    Lisp ideas are a mere stepping stone.
    I conceived this as a substrate of ai.


    BTW: I am not sure what 1 GB is supposed to mean? Do you need
    that much to rebuild ciforth with your changes? FYI, the system
    I outlined above is extremaly bloated by Forth standards, but
    runs happily in few MB. Recompilation needs more memory, but
    currently main "memory eater" is C compilation of few support
    files.

    Ideally the turnkey system (a computer intelligence) uses a
    virtual memory system, using the Terabyte disks and nothing
    else. The extra space is needed to remember interesting tidbits
    from the the Internet. And also to experiment with programs
    she invents herself.

    --
    Waldek Hebisch

    Groetjes Albert
    --
    Temu exploits Christians: (Disclaimer, only 10 apostles)
    Last Supper Acrylic Suncatcher - 15Cm Round Stained Glass- Style Wall
    Art For Home, Office And Garden Decor - Perfect For Windows, Bars,
    And Gifts For Friends Family And Colleagues.

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