Many Forth systems running under an operating system provideNote that it is not Forth-system-specific but operating-system specific.
system-specific capabilities to terminate with an exit status [1].
For example, the following code fragments have stack effect ( n -- ⊥ )
and use n as the process exit status:
SwiftForth "exitstatus ! bye"
VfxForth "exitcode ! bye"
Gforth "(bye)"
ciforth "exit-code ! bye"
mf3 "sysexit"
Post4 "bye-code"
SP-Forth "halt"
Could you suggest some names for the word with this functionality so
that one of them can be standardized?
This word should not output any messages.Which word? Do you propose the functionality of Gforth's (bye)
There are at least three different notions of premature termination of
code execution:
— return from a Forth definition (to the caller)
— terminate a thread/task
— terminate the process
And they should not be confused.
[1] <https://en.wikipedia.org/wiki/Exit_status>
--
Ruvim
For example, the following code fragments have stack effect ( n -- ⊥ )
and use n as the process exit status:
SwiftForth "exitstatus ! bye"
VfxForth "exitcode ! bye"
Gforth "(bye)"
ciforth "exit-code ! bye"
mf3 "sysexit"
Post4 "bye-code"
SP-Forth "halt"
Could you suggest some names for the word with this functionality so that one of
them can be standardized?
This word should not output any messages.
I would like to find a more appropriate name for this word than "bye-status".
`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.
On 2024-11-07 06:56, Ruvim wrote:
I would like to find a more appropriate name for this word than "bye-
status".
(bye) ( u -- )
Seems apropos, short, to the point and indicative of an internal word. Default can be defined to return to the host OS with an exit status `u`,
but maybe be replaced in (unhosted) environments to perform some sort of system reset, power cycle, or other implementation defined system reset.
`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.
TERMINATE could have the same meaning as SIGTERM *:
SIGTERM (Terminated)
This signal is the default signal sent by kill(1) and represents a
user or administrator request that a program shut down [normally].
* Other signals result in abnormal termination.
Same as remarked by minforth: there is a exit-handler chain in
which the user can plug arbitrary routines.
On 2024-11-07 22:50, Anthony Howe wrote:
On 2024-11-07 06:56, Ruvim wrote:
I would like to find a more appropriate name for this word than "bye- status".
(bye) ( u -- )
Seems apropos, short, to the point and indicative of an internal word.
Yes, and because of the latter this name cannot be used for a standard word. Standard words are not internal words, but are part of the public interface.
What about the following options:
badbye ( n -- never )
- because it's probably not normal termination
- if n is 0, then it's false-bad (i.e, good)
goodbye ( n -- never )
- ironically when n is not zero
getout ( n -- never )
- send control very far from here
SIGTERM is a good association with processes.
Perhaps, SIGTERM can be send to another process too.
On 2024-11-08 12:29, Anton Ertl wrote:
mhx@iae.nl (mhx) writes:
Same as remarked by minforth: there is a exit-handler chain in
which the user can plug arbitrary routines.
In Gforth BYE is a deferred word, with the intention that it can be
extended with cleanup actions.
The disadvantage of this approach in connection with the non-0 exit is
that we probably also want to do the same cleanup in those cases. The
best way to deal with that is probably the "EXIT-CODE !" approach.
I think, this variable, if it is required, should be internal.
For example:
variable _system-exit-status 0 _system-exit-status !
: kernel-bye ( -- never )
... \ other actions
_system-exit-status @ (bye)
;
defer bye ' kernel-bye is bye
: bye-with-status ( n -- never )
_system-exit-status ! bye
;
Thus, the old interface is not changed. And `bye-with-status` also does
the same cleanup sequence (if any).
Concerning the usual discussion about the name: I find that the system
is left in the error case with an uncaught THROW in script-execution
mode; in that case an exit code of 1 is returned by Gforth, so it's
not sufficient for communicating more than a binary result to the
calling script. But I have not used non-binary exit codes for
non-Forth programs, either, and I do quite a bit of shell scripting.
Does it mean that "bye" and "bye-failure" is enough?
In any case, while we have (BYE), I don't use it in application
programs.
As an example, when a script is used in Make, it is important to return >nonzero exit status on error.
But the precedent for defining and exposing an internal word has been set in >> the standard with Locals `(local)`. So defining `(bye)` seems reasonable.
`(local)` is a good example when a better names was not found. I'm not sure this
form of naming should be used for standard words.
What about "die" ? ;-)
It is used in 8th and in Perl.
BTW, the name "halt" for that is used in FreePascal. <https://www.freepascal.org/docs-html/rtl/system/halt.html>
Other, more technical variants:
exit-process ( n -- never )
Okay. What name to choose for the word that terminates the thread/task of the caller?
If we take "exit-process" to terminate the own process,
then "exit-thread" or "exit-task" can be used for thread/task.
On 2024-11-07 06:56, Ruvim wrote:
I would like to find a more appropriate name for this word than "bye-status".
(bye) ( u -- )
Seems apropos, short, to the point and indicative of an internal word. Default
can be defined to return to the host OS with an exit status `u`, but maybe be >replaced in (unhosted) environments to perform some sort of system reset, power
cycle, or other implementation defined system reset.
`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.
TERMINATE could have the same meaning as SIGTERM *:
SIGTERM (Terminated)
This signal is the default signal sent by kill(1) and represents a
user or administrator request that a program shut down [normally].
* Other signals result in abnormal termination.
--
Anthony C Howe
achowe@snert.com BarricadeMX & Milters >http://nanozen.snert.com/ http://software.snert.com/
In article <vgj268$2p1e5$1@dont-email.me>,
Anthony Howe <achowe@snert.com> wrote:
On 2024-11-07 06:56, Ruvim wrote:
I would like to find a more appropriate name for this word than
"bye-status".
(bye) ( u -- )
Seems apropos, short, to the point and indicative of an internal word.
Default
can be defined to return to the host OS with an exit status `u`, but
maybe be
replaced in (unhosted) environments to perform some sort of system reset,
power
cycle, or other implementation defined system reset.
I agree that it is the politically correct definition.
However the question was, is it worth it to standardise.
The answer is of course: no.
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 505 |
Nodes: | 16 (2 / 14) |
Uptime: | 64:07:20 |
Calls: | 9,926 |
Calls today: | 2 |
Files: | 13,804 |
Messages: | 6,348,732 |
Posted today: | 2 |