Loading appendixb.tex +13 −13 Original line number Diff line number Diff line Loading @@ -274,28 +274,28 @@ VARIABLE MARKER : ;AND COMPILE EXIT HERE MARKER @ ! ; IMMEDIATE : UNDO ['] NOTHING [COMPILE] ' ! ; ( 238 ) ( The code in this screen is in the public domain.) \end{Screen} \vfill \begin{Screen} ( TODDLER: Example of DOER/MAKE 12/01/83 ) DOER WHY? DOER ANSWER : RECITAL CR ." Your daddy is standing on the table. Ask him 'WHY?' " MAKE WHY? ." To change the light bulb." MAKE ANSWER ." To change the light bulb." BEGIN MAKE WHY? ." Because it's burned out." MAKE WHY? ." Because it was old." MAKE WHY? ." Because we put it in there a long time ago." MAKE WHY? ." Because it was dark!" MAKE WHY? ." Because it was night time!!" MAKE WHY? ." Stop saying WHY?" MAKE WHY? ." Because it's driving me crazy." MAKE WHY? ." Just let me change this light bulb!" F UNTIL ; : WHY? CR WHY? QUIT ; MAKE ANSWER ." Because it's burned out." MAKE ANSWER ." Because it was old." MAKE ANSWER ." Because we put it in there a long time ago." MAKE ANSWER ." Because it was dark!" MAKE ANSWER ." Because it was night time!!" MAKE ANSWER ." Stop saying WHY?" MAKE ANSWER ." Because it's driving me crazy." MAKE ANSWER ." Just let me change this light bulb!" FALSE UNTIL ; : WHY? CR ANSWER QUIT ; \end{Screen} \index{D!DOER/MAKE|)} \vfill appendixc.tex +6 −1 Original line number Diff line number Diff line Loading @@ -68,7 +68,7 @@ can be defined as: (\Forth{}'s control words such as \forth{IF} and \forth{UNTIL} interpret zero as ``false'' and any non-zero value as ``true.'' Before \Forth{} '83, the convention was to indicate ``true'' with the value $1$. Starting with \Forth{} '83, however, ``true'' is indicated with hex \code{FF}, with \Forth{} '83, however, ``true'' is indicated with hex \code{FFFF}, which is the signed number $-1$ (all bits set). \forthb{WITHIN}\index{W!WITHIN} can be defined in high level like this: Loading @@ -76,6 +76,11 @@ which is the signed number $-1$ (all bits set). : WITHIN ( n lo hi+1 -- ?) >R 1- OVER < SWAP R> < AND ; \end{Code} or \begin{Code} : WITHIN ( n lo hi+1 -- ?) OVER - >R - R> U< ; \end{Code} \section{From \Chap{8}} Loading appendixd.tex +12 −8 Original line number Diff line number Diff line Loading @@ -48,20 +48,20 @@ or to allocate growing downward: \ CARDS Shuffle 6-20-83 52 CONSTANT #CARDS CREATE DECK #CARDS ALLOT \ one card per byte : INIT-DECK #CARDS 0 DO I DECK I + C! LOOP ; : CARD ( i -- adr) DECK + ; : INIT-DECK #CARDS 0 DO I I CARD C! LOOP ; INIT-DECK : 'CSWAP ( a1 a2 -- ) \ swap bytes at a1 and a2 2DUP C@ SWAP C@ ROT C! SWAP C! ; : SHUFFLE \ shuffle deck of cards #CARDS 0 DO DECK I + DECK #CARDS CHOOSE + 'CSWAP LOOP ; #CARDS 0 DO I CARD #CARDS CHOOSE CARD 'CSWAP LOOP ; \end{Code} \ifeightyfour\end{enumerate}\fi \section{\Chap{8}} \ifeightyfour\begin{enumerate} \item\fi This will work: \item This will work: \begin{Code} 20 CHOOSE 2 CHOOSE IF NEGATE THEN \end{Code} Loading @@ -69,7 +69,11 @@ But this is simpler: \begin{Code} 40 CHOOSE 20 - \end{Code} \ifeightyfour\end{enumerate}\fi \end{enumerate}\else \begin{Code} : DIRECTION ( n|-n|0 -- 1|-1|0) DUP IF 0< 1 OR THEN ; \end{Code} \fi %% Note: The question was random number between 0 and 19, and -20 and 0. %% The first solution gives between 0 and 19, or -19 and 0. Loading appendixe.tex +1 −1 Original line number Diff line number Diff line Loading @@ -236,7 +236,7 @@ superstring array&``name''&``COLORS''\\ --‐ not\\ +&plus\\ =&equals\\ \{ \}&faces (traditionally called ``curly brackets'')\\ \{ \}&braces (traditionally called ``curly brackets'')\\ {[} {]}&square brackets\\ ``"e\\ '&as prefix: tick; as suffix: prime\\ Loading chapter1.tex +3 −3 Original line number Diff line number Diff line Loading @@ -647,7 +647,7 @@ and gets replaced with a black one. Your entire manual is obsolete. You could have avoided the obsolescence by using the term ``Shipping Clerk'' instead of the name ``Jay,'' the terms ``Bookkeeping Dept. copy and'' ``Shipping Dept. copy'' ``Jay,'' the terms ``Bookkeeping Dept. copy'' and ``Shipping Dept. copy'' instead of ``blue'' and ``orange,'' etc. This example illustrates that in order to maintain correctness in the Loading Loading @@ -1308,7 +1308,7 @@ numbers on your terminal instead of controlling stepper motors. They may print their own names just to let you know they've executed. They may do nothing at all. Using this philosophy you can write a simple by testable version of Using this philosophy you can write a simple but testable version of your application, then successively change and refine it until you reach your goal. Loading Loading @@ -1369,7 +1369,7 @@ But in large applications, \Forth{} comes very close to the speed of assembler. Here are three reasons: First and foremost, \Forth{} is simple. \Forth{}'s use of a data stack% \index{D!Data stacks}% \index{D!Data stacks} greatly reduces the performance cost of passing arguments from word to word. In most languages, passing arguments between modules is one of the main reasons that the use of subroutines inhibits performance. Loading Loading
appendixb.tex +13 −13 Original line number Diff line number Diff line Loading @@ -274,28 +274,28 @@ VARIABLE MARKER : ;AND COMPILE EXIT HERE MARKER @ ! ; IMMEDIATE : UNDO ['] NOTHING [COMPILE] ' ! ; ( 238 ) ( The code in this screen is in the public domain.) \end{Screen} \vfill \begin{Screen} ( TODDLER: Example of DOER/MAKE 12/01/83 ) DOER WHY? DOER ANSWER : RECITAL CR ." Your daddy is standing on the table. Ask him 'WHY?' " MAKE WHY? ." To change the light bulb." MAKE ANSWER ." To change the light bulb." BEGIN MAKE WHY? ." Because it's burned out." MAKE WHY? ." Because it was old." MAKE WHY? ." Because we put it in there a long time ago." MAKE WHY? ." Because it was dark!" MAKE WHY? ." Because it was night time!!" MAKE WHY? ." Stop saying WHY?" MAKE WHY? ." Because it's driving me crazy." MAKE WHY? ." Just let me change this light bulb!" F UNTIL ; : WHY? CR WHY? QUIT ; MAKE ANSWER ." Because it's burned out." MAKE ANSWER ." Because it was old." MAKE ANSWER ." Because we put it in there a long time ago." MAKE ANSWER ." Because it was dark!" MAKE ANSWER ." Because it was night time!!" MAKE ANSWER ." Stop saying WHY?" MAKE ANSWER ." Because it's driving me crazy." MAKE ANSWER ." Just let me change this light bulb!" FALSE UNTIL ; : WHY? CR ANSWER QUIT ; \end{Screen} \index{D!DOER/MAKE|)} \vfill
appendixc.tex +6 −1 Original line number Diff line number Diff line Loading @@ -68,7 +68,7 @@ can be defined as: (\Forth{}'s control words such as \forth{IF} and \forth{UNTIL} interpret zero as ``false'' and any non-zero value as ``true.'' Before \Forth{} '83, the convention was to indicate ``true'' with the value $1$. Starting with \Forth{} '83, however, ``true'' is indicated with hex \code{FF}, with \Forth{} '83, however, ``true'' is indicated with hex \code{FFFF}, which is the signed number $-1$ (all bits set). \forthb{WITHIN}\index{W!WITHIN} can be defined in high level like this: Loading @@ -76,6 +76,11 @@ which is the signed number $-1$ (all bits set). : WITHIN ( n lo hi+1 -- ?) >R 1- OVER < SWAP R> < AND ; \end{Code} or \begin{Code} : WITHIN ( n lo hi+1 -- ?) OVER - >R - R> U< ; \end{Code} \section{From \Chap{8}} Loading
appendixd.tex +12 −8 Original line number Diff line number Diff line Loading @@ -48,20 +48,20 @@ or to allocate growing downward: \ CARDS Shuffle 6-20-83 52 CONSTANT #CARDS CREATE DECK #CARDS ALLOT \ one card per byte : INIT-DECK #CARDS 0 DO I DECK I + C! LOOP ; : CARD ( i -- adr) DECK + ; : INIT-DECK #CARDS 0 DO I I CARD C! LOOP ; INIT-DECK : 'CSWAP ( a1 a2 -- ) \ swap bytes at a1 and a2 2DUP C@ SWAP C@ ROT C! SWAP C! ; : SHUFFLE \ shuffle deck of cards #CARDS 0 DO DECK I + DECK #CARDS CHOOSE + 'CSWAP LOOP ; #CARDS 0 DO I CARD #CARDS CHOOSE CARD 'CSWAP LOOP ; \end{Code} \ifeightyfour\end{enumerate}\fi \section{\Chap{8}} \ifeightyfour\begin{enumerate} \item\fi This will work: \item This will work: \begin{Code} 20 CHOOSE 2 CHOOSE IF NEGATE THEN \end{Code} Loading @@ -69,7 +69,11 @@ But this is simpler: \begin{Code} 40 CHOOSE 20 - \end{Code} \ifeightyfour\end{enumerate}\fi \end{enumerate}\else \begin{Code} : DIRECTION ( n|-n|0 -- 1|-1|0) DUP IF 0< 1 OR THEN ; \end{Code} \fi %% Note: The question was random number between 0 and 19, and -20 and 0. %% The first solution gives between 0 and 19, or -19 and 0. Loading
appendixe.tex +1 −1 Original line number Diff line number Diff line Loading @@ -236,7 +236,7 @@ superstring array&``name''&``COLORS''\\ --‐ not\\ +&plus\\ =&equals\\ \{ \}&faces (traditionally called ``curly brackets'')\\ \{ \}&braces (traditionally called ``curly brackets'')\\ {[} {]}&square brackets\\ ``"e\\ '&as prefix: tick; as suffix: prime\\ Loading
chapter1.tex +3 −3 Original line number Diff line number Diff line Loading @@ -647,7 +647,7 @@ and gets replaced with a black one. Your entire manual is obsolete. You could have avoided the obsolescence by using the term ``Shipping Clerk'' instead of the name ``Jay,'' the terms ``Bookkeeping Dept. copy and'' ``Shipping Dept. copy'' ``Jay,'' the terms ``Bookkeeping Dept. copy'' and ``Shipping Dept. copy'' instead of ``blue'' and ``orange,'' etc. This example illustrates that in order to maintain correctness in the Loading Loading @@ -1308,7 +1308,7 @@ numbers on your terminal instead of controlling stepper motors. They may print their own names just to let you know they've executed. They may do nothing at all. Using this philosophy you can write a simple by testable version of Using this philosophy you can write a simple but testable version of your application, then successively change and refine it until you reach your goal. Loading Loading @@ -1369,7 +1369,7 @@ But in large applications, \Forth{} comes very close to the speed of assembler. Here are three reasons: First and foremost, \Forth{} is simple. \Forth{}'s use of a data stack% \index{D!Data stacks}% \index{D!Data stacks} greatly reduces the performance cost of passing arguments from word to word. In most languages, passing arguments between modules is one of the main reasons that the use of subroutines inhibits performance. Loading