• Re: How robust is INCLUDE

    From Ruvim@ruvim.pinka@gmail.com to comp.lang.forth on Wed Jan 29 03:00:04 2025
    From Newsgroup: comp.lang.forth

    On 2024-12-19 19:22, mhx wrote:
    I wonder if the following code is (partially) ANS compatible,

    [...]

    \ in file inside1.frt
    \ ] CR DUP . R@ . S .  one . two . three . one two * three * DUP TO
    result [
    : MAIN1 ( -- )
         1 2 3 0 LOCALS| result three two one |
         4 >S 5 >R 6
         [ S" inside1.frt" INCLUDED ]  ( at compile time, locals accessible )

    Such loading of a file has an environmental dependency.

    11.6.1.1718:
    | INCLUDED may allocate memory in data space
    | before it starts interpreting the file.

    If it does such allocating, and if code space interlaces with data
    space, your loading of a definition fragment will not work.


    Another possible problem is accessing locals when you place data on the
    return stack. This also introduces an environmental dependency.

    13.3.3.2, d:
    | After a definition's locals have been declared,
    | a program may place data on the return stack. However,
    | if this is done, locals shall not be accessed until
    | those values have been removed from the return stack;


    --
    Ruvim

    --- Synchronet 3.20c-Linux NewsLink 1.2