From: ruvim.pinka@gmail.com   
      
   On 2024-09-03 10:50, Anton Ertl wrote:   
   > Ruvim writes:   
   >> Do you know practical cases of using "include-file" in programs?   
   >   
   > One way I am thinking about is to implement INCLUDED etc. Systems   
   > deal differently with relative filenames for INCLUDED, with less   
   > differences for OPEN-FILE. So if I want to implement a certain   
   > handling of relative filenames for INCLUDED in order to get rid of   
   > system differences, one way to do it is to do it for OPEN-FILE and   
   > then perform INCLUDE-FILE.   
      
   Yes, overriding the system's file search mechanism used by "included" is   
   a very interesting idea!   
      
      
   >   
   >> 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?   
   >   
   > Heinz Schnitter implemented Open Network Forth, a distributed system,   
   > where the parts communicated by sending Forth source code to each   
   > other. One could implement that by having network connections   
   > (telnet-style or ssh-style) between the parts, and the receiver could   
   > INCLUDE-FILE the file-id that represents his end of the connection.   
   > However, Open Network Forth was written around 1984, long before   
   > INCLUDE-FILE was standardized. Bernd Paysan uses ideas from it in his   
   > work, inclluding sending Forth commands between tasks, but AFAIK does   
   > not use INCLUDE-FILE for that.   
      
      
   Such a system must probably be multitasking. Otherwise, the Forth system   
   instance that runs "read-file" is a slaver of the corresponding pipe   
   emitter until the pipe is closed (i.e., until the master wants).   
      
      
      
      
      
   Taking my idea of skipping a BOM (byte-order mark), a program can also   
   skip a shebang line, like this:   
      
    #! /usr/bin/env forth   
      
   I know Gforth has the word "#!" that comments out the rest of the line.   
      
   Using "open-file", "read-line", "reposition-file" and "include-file" is   
   an alternative way for a portable program. Yes, it seems far more   
   complex than a word "#!". But what if you need "#!" for something else   
   (including recognizable things).   
      
      
      
   --   
   Ruvim   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   
|