From e3fc57fb17fe30e418c142f3d4995909fc08b7ea Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 10 Nov 2026 11:28:10 +0000 Subject: [PATCH] docs(dictionary): batch 2 -- D..P (#157) [skip ci] Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01GE3SDvQn5EoxdGufk84zz2 --- docs/reference/v4-dictionary.tsv | 222 +++++++++++++++---------------- 1 file changed, 111 insertions(+), 111 deletions(-) diff --git a/docs/reference/v4-dictionary.tsv b/docs/reference/v4-dictionary.tsv index 63e27537..5ae98578 100644 --- a/docs/reference/v4-dictionary.tsv +++ b/docs/reference/v4-dictionary.tsv @@ -127,117 +127,117 @@ COUNT ( baddr1 -- baddr2 u ) From a counted string: its first character's addres CR ( -- ) Print a new line. CREATE ( -- ) CREATE xxx: an entry whose word leaves the address of its parameter field. CURRENT ( -- addr ) Variable: the vocabulary new definitions go into. -D+ TODO ---- section 5.7: doubles ------------------------------------------------ -D- TODO ---- doubles and mixed ---- -D. TODO -D.R TODO -D0< TODO -D0= TODO -D2* TODO -D2/ TODO -D< TODO -D= TODO -DABS TODO -DECIMAL TODO -DEFAULT-ROUTE ( port -- ) TODO the port, by its number, leads toward every node not told of -DEFER TODO -DEFER@ TODO -DEFINITIONS TODO FORTH-79: new definitions go into the CONTEXT vocabulary from now on. -DEPTH TODO FORTH-79: how many values were on the stack before DEPTH -DMAX TODO -DMIN TODO -DNEGATE TODO -DO TODO -DOES> TODO -DROP TODO -DUMP TODO -DUP TODO ---- stack ---- -ELSE TODO -EMIT TODO EMIT puts the character with what has been printed. Everything the node prints goes through EMIT. A is kept: the words that print have always been free to use it across an EMIT. As v3, only the low 8 bits of the character are printed. A BUFFER FOUND FULL is sent first. It is full when a flush of it ended in a fault -- the stack too deep to begin a message -- and what is printed next is that fault's own message: put where (OUT^) points, it would go past the buffer's end, and (OUT^) would never again be at the end to be flushed (MESH.md 7c.6). -EMPTY-BUFFERS TODO FORTH-79: forget what is in the buffers; nothing is written. -ENCLOSE ( baddr c -- baddr n1 n2 n3 ) TODO in the zero-terminated string at baddr: n1 the offset of the first character that is not c, n2 the offset of the first c after it, n3 the offset of the first character after that run of c. -ENDCASE TODO -ENDOF TODO -ERASE TODO -EXECUTE TODO -EXIT TODO FORTH-79: return from the definition at this point -EXPECT ( baddr n -- ) TODO FORTH-79: characters from the terminal are stored from baddr upward until a new-line or until n have been received; the new-line is taken but not stored. A zero is added after the text, so the buffer must hold n + 1 bytes. No action for n <= 0. SPAN is how many characters were stored (SPAN is not FORTH-79; v3 has it). A line longer than n leaves the rest, its new-line included, to be read next. It is what the prompt reads every line with, with whatever the user has left on the stack beneath it, so it works in (P) -- (P)+0 where the next character goes, (P)+1 how many more may come, (P)+2 where the first went -- and has at most three cells of its own on the data stack (D-2). -FALSE TODO -FENCE TODO -FILL TODO -FIND ( -- xt | 0 ) TODO FORTH-79: the compilation address of the next word in the input stream, or 0 if it is not in the dictionary. -FLUSH TODO As v3: the same. -FORGET TODO FORGET xxx FORTH-79: remove xxx and every word defined after it, in whatever vocabulary; the space they took is free again. A vocabulary that goes is no longer CONTEXT or CURRENT: FORTH is. A word that is not there is an error, and so is one below FENCE, which is where the capsule's own words are (code 10, "Protected word"). -FORTH TODO FORTH-79: the primary vocabulary; it becomes the CONTEXT vocabulary. -GONE ( n node -- ) TODO tell the node that node n is gone. It acts on that only if this node is its centre: it forgets the way to n, and if it is waiting for n's answer the wait ends. -HERE TODO -HEX TODO -HIDDEN TODO -HOLD TODO -I TODO -IF TODO Native if leaves the flag, so both ways out of it drop it (section 2): IF a THEN if L1 drop a jump L2 L1: drop L2: IF a ELSE b THEN if L1 drop a jump L2 L1: drop b L2: -IMMEDIATE TODO -INTERPRET ( -- ) TODO FORTH-79: take words from the input stream until it is exhausted. A word in the dictionary is executed, or, when compiling and not immediate, compiled. Anything else must be a number in the current BASE: it is left on the stack, or compiled as a literal. What is neither, or a compile-only word met while interpreting, abandons the line, with v3's message: UNKNOWN WORD: 'xxx' xxx: compile-only -INVERT TODO -IS TODO -J TODO -KERNEL-WORD ( n -- ) TODO KERNEL-WORD xxx A WORD THAT ASKS THE KERNEL (docs/v4.0.0/ ENGINE.md 3.3). xxx is made a word whose whole body is "write n to the port": n is the number of a request, the port is the node's way to its kernel, and the write blocks the node until the kernel has served it (DECOMPOSITION.md section 6). xxx's arguments are whatever it finds on the data stack and its results are what the kernel leaves there. This is what a word that is a C function in v3 -- BIRTH, BLOCK, BYE -- is on a node. Not FORTH-79 and not in v3, where such a word is registered from C. The constant (PORT) is the port's word address. -KEY TODO -LATEST TODO -LEAVE TODO -LFA TODO -LINK> TODO -LIST TODO ---- LIST ---------------------------------------------------------------------- ( n -- ) as v3: a new line, "Block n", then sixteen lines of 64 characters, each after its number, and an empty line. SCR is left holding n. A character that is not printable is shown as a blank. (Q)+0 is the line, (Q)+1 the column, (Q)+2 the block's number. -LITERAL ( x -- ) TODO FORTH-79: if compiling, compile x as a literal -LOAD ( n -- ) TODO FORTH-79: interpret block n, then go on with what follows. -LOG-DEBUG TODO -LOG-DEBUG" TODO -LOG-DEBUG-STR ( baddr u -- ) TODO -LOG-ERROR TODO -LOG-ERROR" TODO -LOG-ERROR-STR ( baddr u -- ) TODO -LOG-INFO TODO -LOG-INFO" TODO -LOG-INFO-STR ( baddr u -- ) TODO -LOG-LEVEL! ( n -- ) TODO as v3: a level below 0 is 0, one above 4 is 4 -LOG-LEVEL@ TODO -LOG-TEST TODO -LOG-TEST" TODO -LOG-TEST-STR ( baddr u -- ) TODO -LOG-WARN TODO -LOG-WARN" TODO -LOG-WARN-STR ( baddr u -- ) TODO -LOOP TODO -LSHIFT TODO ---- shifts ---- As v3, a count that is negative or as large as the cell is wide is an error (code 9, "Shift count out of range"). -M* TODO The product's sign waits in (F), not on the return stack, for the same reason as SM/REM's. -M+ TODO -M- TODO -M/MOD TODO -MAX TODO -MIN TODO -MINT-ZUSE TODO -MOD TODO -MOVE TODO FORTH-79: n cells from addr1 to addr2, the cell at addr1 first. -NAME> TODO -NEGATE TODO -NEIGHBOUR ( node port -- ) TODO the node on the other end of the port, by its number; 0: none, or a device. Whoever wires the node tells it, and tells it again when the wiring changes. It is how a node knows who its centre is, the one node whose GONE it believes: (CENTRE). -NFA TODO -NO-ROUTE ( node -- ) TODO forget the way to that node, if one is known: what is for it then goes by the way for every node not told of, if there is one. The last way in the table takes its place. -NO-ROUTES ( -- ) TODO forget every way: for when the wiring has changed -NODE-ERROR TODO FORTH-79: clear the return stack, set execution mode, return control to the terminal; no message is given. The data stack is left as it is. NODE-ERROR, by name: how a definition written in FORTH raises an error. A store of a code that is not zero is the trap of D-18 -- the word goes no further, the message for the code is printed (-1: the word has printed its own) and the line ends with ERROR. The codes are listed in core.f18. -NOP TODO -NOT TODO -NUMBER ( baddr -- d ) TODO FORTH-79. What is not a number gives 0 and sets NODE-ERROR. -OCTAL TODO -OF TODO -OR TODO -ORDER ( -- ) TODO as v3's, but true: where names are looked for, and where new ones go -OVER TODO -PAD TODO -PAGE ( -- ) TODO clear the screen and put the cursor at the top, as v3: ESC [2J ESC [H -PFA TODO -PICK ( n -- x ) TODO FORTH-79: a copy of the n-th value, not counting n itself. 1 PICK is DUP, 2 PICK is OVER. n less than one is an error. -PORT! ( w port -- ) TODO write a cell to the port, by its number. It waits until the neighbour has taken it. This is how a node is sent a capsule of F18 code (docs/v4.0.0/MESH.md section 5): the cells go as they are, not as a message, to a node that is executing from its ports. +D+ ( d1 d2 -- d3 ) Add two double-cell numbers. +D- ( d1 d2 -- d3 ) Subtract d2 from d1. +D. ( d -- ) Print the double-cell number d, then a blank. +D.R ( d width -- ) Print d right-justified in a field of width characters. +D0< ( d -- flag ) True if d is negative. +D0= ( d -- flag ) True if d is zero. +D2* ( d1 -- d2 ) Shift d1 left one bit. +D2/ ( d1 -- d2 ) Shift d1 right one bit, keeping the sign. +D< ( d1 d2 -- flag ) True if d1 is less than d2. +D= ( d1 d2 -- flag ) True if d1 equals d2. +DABS ( d -- ud ) The absolute value of d. +DECIMAL ( -- ) Set BASE to ten. +DEFAULT-ROUTE ( port -- ) The port, by its number, leads toward every node this node has not been told of. +DEFER ( -- ) DEFER xxx: define xxx, whose action is set later by IS; run unset, it is error 15. +DEFER@ ( -- xt ) DEFER@ xxx: the execution token xxx runs now; compiled when compiling. +DEFINITIONS ( -- ) New definitions go into the CONTEXT vocabulary from now on. +DEPTH ( -- n ) The number of values on the stack before DEPTH. +DMAX ( d1 d2 -- d3 ) The greater of two doubles. +DMIN ( d1 d2 -- d3 ) The lesser of two doubles. +DNEGATE ( d -- -d ) Negate a double-cell number. +DO ( limit index -- ) Compile-only: begin a counted loop, ended by LOOP or +LOOP. +DOES> ( -- ) Compile-only: in a defining word, what the words it defines do, with their parameter field's address on the stack. +DROP ( x -- ) Drop the top value. +DUMP ( baddr u -- ) Print u bytes from baddr in the current BASE, with their addresses. +DUP ( x -- x x ) Copy the top value. +ELSE ( -- ) Compile-only: the other branch of IF ... ELSE ... THEN. +EMIT ( c -- ) Print the character c. +EMPTY-BUFFERS ( -- ) Forget what is in the block buffers; nothing is written. +ENCLOSE ( baddr c -- baddr n1 n2 n3 ) Find a word delimited by c in the string at baddr: n1 its start, n2 its end, n3 the offset after the delimiter. +ENDCASE ( x -- ) Compile-only: end a CASE selection, dropping the value if no OF matched. +ENDOF ( -- ) Compile-only: end an OF branch; go on after ENDCASE. +ERASE ( baddr u -- ) Fill u bytes from baddr with zeros. +EXECUTE ( xt -- ) Run the word whose execution token is xt. +EXIT ( -- ) Compile-only: return from the definition at this point. +EXPECT ( baddr n -- ) Read up to n characters, or a line, from the terminal into baddr; SPAN holds how many. +FALSE ( -- 0 ) Constant: the false flag, zero. +FENCE ( -- addr ) Variable: FORGET will not remove anything below the address it holds. +FILL ( baddr u c -- ) Fill u bytes from baddr with the byte c. +FIND ( -- xt | 0 ) FIND xxx: the execution token of xxx, from the input stream, or 0 if it is not found. +FLUSH ( -- ) Write every changed block (SAVE-BUFFERS). +FORGET ( -- ) FORGET xxx: remove xxx and every word defined after it, never below FENCE. +FORTH ( -- ) Make FORTH, the primary vocabulary, the CONTEXT vocabulary. +GONE ( n node -- ) Tell the node that node n is gone; it acts on that only if this node is its centre. +HERE ( -- addr ) The address of the next free dictionary cell. +HEX ( -- ) Set BASE to sixteen. +HIDDEN ( -- ) Hide the newest entry: it cannot be found until revealed. +HOLD ( c -- ) Pictured output: put the character c in front of the string being built. +I ( -- n ) Compile-only: the index of the innermost DO loop. +IF ( flag -- ) Compile-only: run what follows if flag is not zero, else skip to ELSE or THEN. +IMMEDIATE ( -- ) Make the newest definition run when compiling instead of being compiled. +INTERPRET ( -- ) Interpret words from the input stream until it is exhausted. +INVERT ( x1 -- x2 ) Invert every bit. +IS ( xt -- ) IS xxx: make the deferred word xxx run xt; compiled when compiling. +J ( -- n ) Compile-only: the index of the next outer DO loop. +KERNEL-WORD ( n -- ) KERNEL-WORD xxx: define xxx, a word that asks the kernel to do request n (as BYE, BLOCK). +KEY ( -- c ) Wait for a key and leave its character. +LATEST ( -- xt ) The newest entry of the CURRENT vocabulary. +LEAVE ( -- ) Compile-only: leave the innermost DO loop at its next LOOP or +LOOP. +LFA ( xt -- addr ) The link field of the entry (>LINK). +LINK> ( addr -- xt ) The entry that a link field points to. +LIST ( n -- ) Print block n as 16 lines of 64 characters; SCR holds n. +LITERAL ( x -- ) If compiling, compile x as a literal. +LOAD ( n -- ) Interpret block n, then go on with what follows. +LOG-DEBUG ( -- 4 ) Constant: the debug log level. +LOG-DEBUG" ( -- ) LOG-DEBUG" text": log the text at the debug level. +LOG-DEBUG-STR ( baddr u -- ) Log the string at the debug level. +LOG-ERROR ( -- 0 ) Constant: the error log level. +LOG-ERROR" ( -- ) LOG-ERROR" text": log the text at the error level. +LOG-ERROR-STR ( baddr u -- ) Log the string at the error level. +LOG-INFO ( -- 2 ) Constant: the info log level. +LOG-INFO" ( -- ) LOG-INFO" text": log the text at the info level. +LOG-INFO-STR ( baddr u -- ) Log the string at the info level. +LOG-LEVEL! ( n -- ) Set the log level, held to 0 .. 4: messages at or below it are printed. +LOG-LEVEL@ ( -- n ) The log level. +LOG-TEST ( -- 3 ) Constant: the test log level. +LOG-TEST" ( -- ) LOG-TEST" text": log the text at the test level. +LOG-TEST-STR ( baddr u -- ) Log the string at the test level. +LOG-WARN ( -- 1 ) Constant: the warning log level. +LOG-WARN" ( -- ) LOG-WARN" text": log the text at the warning level. +LOG-WARN-STR ( baddr u -- ) Log the string at the warning level. +LOOP ( -- ) Compile-only: end a DO loop, adding one to the index. +LSHIFT ( x1 u -- x2 ) Shift x1 left u bits; a count that is negative or a cell or more gives 0. +M* ( n1 n2 -- d ) Multiply: the double-cell product, signed. +M+ ( d1 n -- d2 ) Add a single-cell number to a double. +M- ( d1 n -- d2 ) Subtract a single-cell number from a double. +M/MOD ( d n1 -- n2 n3 ) Divide d by n1: n2 the remainder, n3 the quotient. +MAX ( n1 n2 -- n3 ) The greater of two numbers. +MIN ( n1 n2 -- n3 ) The lesser of two numbers. +MINT-ZUSE ( -- ) Mint the real Zuse onto a second stick: asks for the stick, writes nothing until YES (the kernel's word; STICK.md 6a). +MOD ( n1 n2 -- n3 ) The remainder of n1 divided by n2. +MOVE ( addr1 addr2 n -- ) Copy n cells from addr1 to addr2, the first cell first. +NAME> ( baddr -- xt ) The entry whose name field is at baddr. +NEGATE ( n -- -n ) Negate. +NEIGHBOUR ( node port -- ) Record the node on the other end of the port, by its number; 0: none. +NFA ( xt -- baddr ) The name field of the entry (>NAME). +NO-ROUTE ( node -- ) Forget the way to that node, if one is known. +NO-ROUTES ( -- ) Forget every way to every node: for when the wiring has changed. +NODE-ERROR ( -- addr ) Variable: storing a non-zero code raises that error -- the word goes no further and the line ends with ERROR. +NOP ( -- ) Do nothing. +NOT ( flag1 -- flag2 ) True if flag1 is zero (as 0=). +NUMBER ( baddr -- d ) Convert the counted string at baddr to a double; what is not a number gives 0 and sets NODE-ERROR. +OCTAL ( -- ) Set BASE to eight. +OF ( x1 x2 -- | x1 ) Compile-only: in CASE, run the branch to ENDOF if x1 equals x2. +OR ( x1 x2 -- x3 ) Bitwise or. +ORDER ( -- ) Print where names are looked for, and where new ones go. +OVER ( x1 x2 -- x1 x2 x1 ) Copy the second value to the top. +PAD ( -- baddr ) A scratch area for text. +PAGE ( -- ) Clear the screen and put the cursor at the top. +PFA ( xt -- addr ) The parameter field of the entry. +PICK ( n -- x ) A copy of the n-th value, not counting n itself: 1 PICK is DUP. +PORT! ( w port -- ) Write a cell to the port, by its number; waits until the neighbour reads it. Q.* TODO ---- multiply ---- Q.+ TODO ---- the double words under other names ---- Q.- TODO