Sysop: | Amessyroom |
---|---|
Location: | Fayetteville, NC |
Users: | 43 |
Nodes: | 6 (0 / 6) |
Uptime: | 94:23:01 |
Calls: | 290 |
Calls today: | 1 |
Files: | 904 |
Messages: | 76,378 |
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?
On Mon, 2 Sep 2024 20:11:25 +0000, Ruvim wrote:
Do you know practical cases of using "include-file" in programs?[..]
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?
Ruvim <ruvim.pinka@gmail.com> 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.
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.
- anton
On 02/09/2024 21:11, Ruvim wrote:
Do you know practical cases of using "include-file" in programs?
I can't imagine how this word could be used in standard programs.
Only one idea: to skip BOM (byte-order mark) before include the file
contents.
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?
I've used it to redefine INCLUDED
: included ( ... caddr u -- ... )
r/o open-path-file throw include-file
;
where OPEN-PATH-FILE takes a string specifying a list of alternative
relative paths to Forth source files which it tries in turn to open. It
does this by creating an absolute directory path and calls OPEN-FILE. If
an open succeeds it returns the file-id to be included by INCLUDE-FILE.
If no relative path succeeds an exception is thrown.
I've used it to test a program on several different Forth systems, each
of which has its own way of handling relative directory paths but they
all work with an absolute path.
Do you know practical cases of using "include-file" in programs?
I can't imagine how this word could be used in standard programs.
Only one idea: to skip BOM (byte-order mark) before include the file contents.
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?
Also, `REQUIRED` does not load a file that was loaded by `INCLUDED`. >`INCLUDE-FILE` is free of that too.
Ruvim <ruvim.pinka@gmail.com> writes:
Also, `REQUIRED` does not load a file that was loaded by `INCLUDED`. >>`INCLUDE-FILE` is free of that too.
Yes, but why would anyone use REQUIRED or REQUIRE on a file that he
intends to include even if it has been INCLUDED before?
- 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 2024: https://euro.theforth.net
Do you know practical cases of using "include-file" in programs?
Hi Marcel, the Mac Cocoa interface for i4 uses INCLUDE-FILE
to deal with code pasted in the OS clipboard. BTW same for
VFX and VFX64. I needed a portable/standard word, 'et voila'.
I don't receive VFX updates anymore (I probably said something
offensive), so can't try.