On Mon, 2 Sep 2024 20:11:25 +0000, Ruvim wrote:
Do you know practical cases of using "include-file" in programs?
>
[..]
Using other system-specific means, this word can probably be used to
organize inter-process communication: when a file descriptor (e.g. a
pipe) is passed from one process to another and used as the input
source. But why do you need to load Forth code this way?
My SPICE simulator INCLUDE's pre-processed netlists.
A pre-processor takes (again, INCLUDE's) the industrial-standard
netlist and rewrites it to Forth.
One can also write the netlist directly using Forth, but not
every engineer is able or willing to do that.
Debugging is easy: the original netlist runs on standard SPICE
programs and its results can be compared directly to iSPICE's
output when it uses the pre-processed netlist.
The principle works for other applications too. Here some
examples from my dfwforth/include directory:
FORTH> grep "INCLUDE" /mnt/d/dfwforth/include/*.frt
/assemble.frt:319: =ASM-NAME COUNT INCLUDED
/backtrac.frt:132: ['] INCLUDE-FILE OF
/dialogs.frt:116: R> COUNT INCLUDED
/eplot.frt:777: SWAP @ ?DUP IF COUNT INCLUDED ( header) ENDIF
/eplot.frt:796: SWAP @ ?DUP IF COUNT INCLUDED ( header) ENDIF
/eplot.frt:819: SWAP @ ?DUP IF COUNT INCLUDED ( header) ENDIF
/eplot.frt:838: SWAP @+ SWAP >S ?DUP IF COUNT INCLUDED ( head
/eplot.frt:882: :headname @ ?DUP IF COUNT INCLUDED
/eplot.frt:895: :dataname @ COUNT INCLUDED ;
/graphbench.frt:261:#63 #check [IF] INCLUDE gtk3/benchmarks.frt [T
/iwords1.frt:4:CR .( FORTH.LOG : edit out garbage first, then INCLUDE i
/lprof.frt:357:\ Instead of INCLUDE name , IN name , S" name" INCLUDED
/lprof.frt:367: S" !!!!!!!!.$$$" INCLUDED
/lprofile.frt:198:\ Instead of INCLUDE name , IN name , S" name" INCLUD
/lprofile.frt:207: S" !!!!!!!!.$$$" INCLUDED ;
/playwav.frt:17:[IF] INCLUDE pwavlinu.frt
/playwav.frt:21:[IF] INCLUDE pwavlinu.frt
/playwav.frt:25:[IF] INCLUDE pwavewin.frt
/runsteady.frt:620: inpbuf #11 cnt MIN S" *| INCLUDE " COMP
/syssim.frt:772: EVAL" ANEW __syssim__" S" spf_model.frt" INCLUDED ;
/syssim.frt:812: CR ." SPF-INCLUDE -- load spf_model.frt control/simu
-marcel