Sujet : Re: bye with exit status
De : ruvim.pinka (at) *nospam* gmail.com (Ruvim)
Groupes : comp.lang.forthDate : 07. Nov 2024, 12:56:38
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <vgi9tn$2kmb0$1@dont-email.me>
References : 1 2 3 4
User-Agent : Mozilla Thunderbird
On 2024-11-06 22:27, mhx wrote:
iForth:
T: BYE ( -- ) 0 TERMINATE T; ANS
TERMINATE IFORTH
( n -- )
Disconnect the server from the processor. Remove the server
program on the host computer and let the server return the
implementation defined error code n to the operating system.
See also: BYE
: TERMINATE
??CR [ =FILES ] [IF] FLUSH BLOCK-FID @ ?DUP
IF CLOSE-FILE DROP 0 BLOCK-FID ! THEN
[THEN]
BYE! T; ( error-level -- )
BYE! IFORTH
( -- )
Send the 'disconnect server' command over the boot link to the
server (if there is one). The server disconnects upon receiving
this message and exits itself. All knowledge about open files
is lost. If there is no server this command is the same as BYE .
See also: BYE
Same as remarked by minforth: there is a exit-handler chain in
which the user can plug arbitrary routines.
The chained handlers were very popular with Hanno Schwalm because
he loved generating executables. I don't use them myself because
iForth is the default shell for my main activities.
It's common thing in mature Forth systems.
For example, in SP-Forth/4 the following chains are used:
AT-PROCESS-STARTING
AT-PROCESS-FINISHING
AT-THREAD-STARTING
AT-THREAD-FINISHING
They are implemented using the "Scattering a Colon Definition" technique [1].
When a chain of actions is used, any additional actions or output messages on termination (if any) are controlled by the user/program.
I meant that `bye-status` shall not show any messages by itself.
I would like to find a more appropriate name for this word than "bye-status".
I think the name "bye-code" is worse than "bye-status" because the term "code" has many meanings and is used with another meaning in the names like `CODE` and `;CODE`.
`terminate` is a good candidate, but it's unclear what it should terminate — a thread/task, or a process, or the own process, or the own thread.
In SP-Forth/4 `TERMINATE` terminates the thread of the caller.
[1] <
https://rawcdn.githack.com/rufig/spf4-utf8/master/devel/~mlg/ScatColn/ScatteredColonDef.html>
-- Ruvim