Deutsch   English   Français   Italiano  
<v5fjkr$1p13i$1@dont-email.me>

View for Bookmarking (what is this?)
Look up another Usenet article

Path: ...!weretis.net!feeder8.news.weretis.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Krishna Myneni <krishna.myneni@ccreweb.org>
Newsgroups: comp.lang.forth
Subject: 0 SET-ORDER why?
Date: Tue, 25 Jun 2024 18:25:15 -0500
Organization: A noiseless patient Spider
Lines: 149
Message-ID: <v5fjkr$1p13i$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Wed, 26 Jun 2024 01:25:16 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="6dc768f456b76527287d97634d4e65d3";
	logging-data="1868914"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX1/nvlSdgZ+sCBm5Tvz1oUsN"
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:x1rpb3+MOhtbLlSe4R9Bvf0fNGo=
Content-Language: en-US
Bytes: 5044

Why is 0 a valid argument to SET-ORDER (from the optional Search-Order 
word set)? It can leave a Forth system in a non-recoverable state.

---
16.6.1.2197

SET-ORDER ( widn . . . wid1 n – – )
Set the search order to the word lists identified by widn . . . wid1. 
Subsequently, word list wid1 will be searched first, and word list widn 
searched last.

If n is zero, empty the search order.

If n is minus one, set the search order to the implementation-defined 
minimum search order. The minimum search order shall include the words 
FORTH-WORDLIST and SET-ORDER.

A system shall allow n to be at least eight.
---

Sentences are separated for emphasis: "If n is zero, empty the search 
order."  Why?

In kForth (32/64), the sequence

0 SET-ORDER

leaves the Forth system in a non-recoverable state, and I have to use 
Ctrl-C to break out back to the OS shell. This appears to be true in 
Gforth as well, although Gforth traps Ctrl-C, so maybe one has to kill 
the process from another shell.

See the examples below.

-- Krishna Myneni


=== kForth example ===
kForth-64 v 0.4.5	 (Build: 2024-03-30)
Copyright (c) 1998--2023 Krishna Myneni
Contributions by: dpw gd mu bk abs tn cmb bg dnw imss
Provided under the GNU Affero General Public License, v3.0 or later


Ready!
order    \ upon startup without command line args
[Forth]  Root   ok

\ set to the system's minimum search order (see 16.6.2.1965)
only
  ok
order
Root   ok  \ minimum search order only contains the root wordlist

\ words in the root wordlist
words
5 words.
ORDER          SET-ORDER      FORTH-WORDLIST FORTH          WORDS
  ok

\ we can recover with the word FORTH (16.6.2.1590)
forth
  ok
order
[Forth]  Root   ok  \ back to startup state


only
  ok
order
Root   ok

\ What does 0 SET-ORDER do?
0 set-order
  ok
order   \ the word ORDER is no longer in the search order

ORDER
Line 10:  VM Error(-13): Undefined word
order
forth   \ the word FORTH is no longer in the search order

FORTH
Line 11:  VM Error(-13): Undefined word
forth
bye

BYE     \ we can't get back to OS shell without Ctrl-C
Line 12:  VM Error(-13): Undefined word
bye
=== end of kForth example ===

=== Gforth example ===
Gforth 0.7.9_20220120
Authors: Anton Ertl, Bernd Paysan, Jens Wilke et al., for more type 
`authors'
Copyright © 2021 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later 
<https://gnu.org/licenses/gpl.html>
Gforth comes with ABSOLUTELY NO WARRANTY; for details type `license'
Type `help' for basic help
   ok
order Forth Forth Root     Forth  ok  \ on startup

only  ok   \ minimum search order ?
order Root Root     Forth  ok

\ words in the Root wordlist
words
order set-order forth-wordlist Forth words  ok
forth  ok
order Forth Root     Forth  ok  \ recovered but different from startup

only  ok
order Root Root     Forth  ok
0 set-order  ok
order    \ ORDER is no longer in the search order
*the terminal*:11:1: error: Undefined word
 >>>order<<<
Backtrace:
kernel/int.fs:321:10:                    0 $7F0DAB00C3A0 throw

forth   \ FORTH is no longer in the search order
*the terminal*:12:1: error: Undefined word
 >>>forth<<<
Backtrace:
kernel/int.fs:321:10:                    0 $7F0DAB00C3A0 throw

bye     \ BYE is no longer in the search order
*the terminal*:13:1: error: Undefined word
 >>>bye<<<
Backtrace:
kernel/int.fs:321:10:                    0 $7F0DAB00C3A0 throw

\ Ctrl-C does not return to OS shell (trapped by Gforth)
*the terminal*:13:1: error: User interrupt                         |o: 
  Forth
 >>>bye<<<
Backtrace:
kernel/input.fs:216:30:                  0 $7F0DAB019438 throw
kernel/input.fs:216:36:                  1 $7F0DAB00E348 get-input-colored
except.fs:83:2:                          2 $7F0DAB024DD8 execute  [catch 
frame]
kernel/int.fs:654:5:                     3 $7F0DAB00DE38 catch
                                          4 $7F0DB903FFC0
kernel/int.fs:658:5:                     5 $7F0DAB00DEA0 bt-rp0-catch
=== end of Gforth example ===