home *** CD-ROM | disk | FTP | other *** search
/ ARM Club 3 / TheARMClub_PDCD3.iso / hensa / programming / forthmacs / htmldocs / !Forthmacs / docs / html / guide < prev    next >
Encoding:
Text File  |  1996-02-23  |  12.7 KB  |  264 lines

  1. <!-- Forthmacs Formatter generated HTML output -->
  2. <html>
  3. <head>
  4. <title>Glossary Notation</title>
  5. </head>
  6. <body>
  7. <h1>Glossary Notation</h1>
  8. <hr>
  9. <p>
  10. This chapter describes the notation used in the Master Glossary.  This chapter 
  11. is based on the ANS manual.  
  12. <p>
  13. <p>
  14. <h2>Order</h2>
  15. <p>
  16. The glossary definitions are listed in ASCII alphabetical order.  
  17. <p>
  18. <br><code>         Example Glossary Line:</code><br>
  19. <p>
  20. <br><code>            Name       Stack     Input Stream   Attributes    Pronunciation</code><br>
  21. <p>
  22. <br><code>            ABORT"     flag --        ccc"        C,I           abort-quote</code><br>
  23. <p>
  24. <p>
  25. <h2>Capitalization</h2>
  26. <p>
  27. Depending on the device you are reading this manual on, Forth keywords will be 
  28. printed bold, capitilized or just as typed.  However, in actual use, the word 
  29. names should always be typed in lower case.  
  30. <p>
  31. <p>
  32. <h2>Stack Notation</h2>
  33. <p>
  34. The stack parameters input to and output from a definition are described using 
  35. the notation: 
  36. <p>
  37. <br><code>                 before -- after</code><br>
  38. <br><code>    </code><br>
  39. <br><code>                         before  stack parameters before execution</code><br>
  40. <br><code>                         after   stack parameters after execution</code><br>
  41. <p>
  42. In this notation, the top of the stack is to the right.  
  43. <p>
  44. Unless otherwise noted, all stack notation describes what happens at execution 
  45. time.  If it applies at compile time, the line is followed by: compiling .  
  46. <p>
  47. <p>
  48. <h2>Input Stream Text</h2>
  49. <p>
  50. Text collected from the input stream, if any, is shown in italics following the 
  51. stack parameters.  The character which marks the end of the input text is the 
  52. "delimiter".  If the delimiter is the space character, it is not shown.  If the 
  53. delimiter is any character other than space, it is shown at the end of the input 
  54. text field.  In the example above, the Input Text field is shown as ccc" and the 
  55. delimiter is the " character.  
  56. <p>
  57. <p>
  58. <h2>Attributes</h2>
  59. <p>
  60. <p><pre>
  61.         Annotations indicate attributes of the defined words:
  62.                 C  The word may only be used during compilation of a colon
  63.                    definition
  64.                 I  Indicates that the word is IMMEDIATE and will execute
  65.                    during compilation, unless special action is taken.
  66.                 M  This word has potential multiprogramming impact.
  67.                    See:  "Multitasking"
  68.                 System  The word appears in the SYSTEM vocabulary.
  69.                 Hidden  The word appears in the HIDDEN vocabulary.
  70.                 83Std   The word is part of the 83 Standard.
  71.                 ANS     The word is part of the ANS standard
  72.                 F83 The word is not part of the 83 Standard, but it
  73.                    appears in the public domain F83 model, from
  74.                    which this system is loosely derived.
  75.                 Deferred  The word is "deferred"; it's behavior may
  76.                    be altered by installing a different implementation
  77.                    of the word.  See: DEFER IS
  78.                 Default   The word is the normal or "default" implementation
  79.                    of some other "deferred" word.
  80. </pre><p>
  81. <p>
  82. <p>
  83. <h2>Pronunciation</h2>
  84. <p>
  85. Then natural language pronunciation of the word name is shown at the right-hand 
  86. side of the line.  
  87. <p>
  88. <p>
  89. <h2>Stack Parameters</h2>
  90. <p>
  91. The Risc-OS Forthmacs stacks contain 32-bit integers for both stacks.  
  92. <p>
  93. Unless otherwise stated, all references to numbers apply to "normal" numbers.  
  94. The implied range of values is shown as {from..to}.  The content of an address 
  95. is shown by double braces, particularly for the contents of variables, i.e.,  <code><A href="_smal_AJ#159"> base </A></code> 
  96. {{2..72}}.  
  97. <p>
  98. The following are the stack parameter abbreviations and types of numbers used 
  99. throughout the glossary.  These abbreviations may be suffixed with a digit to 
  100. differentiate multiple parameters of the same type.  
  101. <p>
  102. <p><pre>
  103.                 Stack   Number                  Range in           Field
  104.                 Abbrv.  Type                    Decimal            Width
  105.                 flag    boolean                 0=false, else=true normal
  106.                 true    boolean                 -1 (as a result)   normal
  107.                 false   boolean                 0                  normal
  108.                 b       bit                     {0..1}             1
  109.                 char    char                    {0..255}           7
  110.                 8b      8 arbitrary bits        not applicable     8
  111.                 16b     16 arbitrary bits       not applicable     16
  112.                 32b     32 arbitrary bits       not applicable     32
  113.                 n       number (normal)
  114.                                    {-2,147,483,648..2,147,483,647} 32
  115.                 +n      positive number         {0..2,147,483,647} 32
  116.                 u       unsigned number         {0..4,294,967,295} 32
  117.                 d       double                  {                } 64
  118.         ud      unsigned double         {                } 64
  119.                 adr     address                 {0..4,294,967,295} 32
  120.                 sys     0, 1, or more system
  121.                         dependent stack entries not applicable     na
  122.                 acf     compilation address     {origin..here}     32
  123.                 anf     name field address      {origin..here}     32
  124.                 alf     link field address      {origin..here}     32
  125.                 apf     parameter field address {origin..here}     32
  126.                 pstr    address of packed string 
  127.                                                 {0..4,294,967,295} 32
  128.         Any other symbol refers to a "normal", the same as n above.
  129. </pre><p>
  130. <p>
  131. <p>
  132. <h2>Input Text Examples</h2>
  133. <p>
  134. <p><pre>
  135.         name
  136.                 An arbitrary FORTH word accepted from the input stream.
  137.                 This notation refers to text from the input stream, not
  138.                 to values on the data stack.  Such a word never contains
  139.                 blank characters.
  140.         ccc
  141.                 A sequence of arbitrary characters accepted from the input
  142.                 stream until the first occurrence of a specified delimiting
  143.                 character.  The delimiter is accepted (removed) from the
  144.                 input stream, but is not one of the characters ccc and is
  145.                 therefore not otherwise processed.  This notation refers to
  146.                 text from the input stream, not to values on the data stack.
  147.                 Unless noted otherwise, the number of characters accepted
  148.                 may be from 0 to 255.
  149.         filename
  150.                 The name of a disk file.  See the chapter "Files" for
  151.                 more information about file names.
  152.         pattern
  153.                 A filename with "wildcards" used to specify several file
  154.                 names at once.  See the chapter "Files" for more
  155.                 information about patterns.
  156.         directory
  157.                 A list of names specifying how to find a particular
  158.                 disk directory (also known as a "folder"). See the chapter
  159.                 "Files" for more information about directories.
  160. </pre><p>
  161. <p>
  162. <p>
  163. <h2>References to other words and definitions</h2>
  164. <p>
  165. Glossary definitions may refer to other glossary definitions or to definitions 
  166. of terms.  Such references are made using "See:".  
  167. <p>
  168. <p>
  169. <h2>Definitions of terms</h2>
  170. <p>
  171. <p>
  172. <h2>Input Stream</h2>
  173. <p>
  174. Risc-OS Forthmacs, because of it's emphasis on files, does not follow the Forth 
  175. 83 Standard with respect to the Input Stream.  
  176. <p>
  177. Here's what the Standard has to say about the Input Stream: 
  178. <p>
  179. The input stream is a sequence of characters available to the system, for 
  180. processing by the text interpreter.  The input stream conventionally may be 
  181. taken from the current input device (via the text input buffer) and mass storage 
  182. (via a block buffer).   <code><A href="_smal_AU#164"> blk </A>,</code>  <code><A href="_smal_AB#121"> >in </A>,</code>  <code><A href="_smal_BM#2f4"> tib </A>,</code> 
  183. and  <code><A href="_smal_BL#83"> #tib </A></code> specify the input stream.  
  184. Words using or altering  <code><A href="_smal_AU#164"> blk </A>,</code>  <code><A href="_smal_AB#121"> >in </A>,</code>  <code><A href="_smal_BM#2f4"> tib </A>,</code> 
  185. and  <code><A href="_smal_BL#83"> #tib </A></code> are responsible for 
  186. maintaining and restoring control of the input stream.  
  187. <p>
  188. The input steam extends from the offset value of  <code><A href="_smal_AB#121"> >in </A></code> 
  189. to the size of the input stream.  If  <code><A href="_smal_AU#164"> blk </A></code> 
  190. is zero the input stream is contained within the area addressed by  <code><A href="_smal_BM#2f4"> tib </A></code> 
  191. and is  <code><A href="_smal_BL#83"> #tib </A></code> bytes long.  If  <code><A href="_smal_AU#164"> blk </A></code> 
  192. is non-zero the input stream is contained within the block buffer specified by  <code><A href="_smal_AU#164"> blk </A></code> 
  193. and is 1024 bytes long.  
  194. <p>
  195. Here's how Risc-OS Forthmacs really implements the Input Stream: 
  196. <p>
  197. The input stream is a sequence of characters available to the system, for 
  198. processing by the text interpreter.  The variable IN-FILE contains the file 
  199. descriptor of the file supplying the characters of the input stream.  That file 
  200. may be a disk file or some other "special file".  
  201. <p>
  202. The most important kind of special file is the "Expect File".  The Expect File 
  203. supplies characters received from the keyboard as read by the word  <code><A href="_smal_AQ#1f0"> expect </A></code> 
  204. .  
  205. <p>
  206. All of the operations which apply to files also apply to the input stream, i.e.   <code><A href="_smal_AX#1f7"> fgetc </A></code>  <code><A href="_smal_BB#1f9"> fgets </A></code>  <code><A href="_smal_AF#215"> ftell </A></code>  <code><A href="_smal_AA#210"> fseek </A></code> 
  207. etc.  
  208. <p>
  209. The variables  <code><A href="_smal_AU#164"> blk </A></code> and  <code><A href="_smal_AB#121"> >in </A></code> 
  210. are not implemented.  The Expect File does indeed store the current keyboard 
  211. line in the buffer starting at  <code><A href="_smal_BM#2f4"> tib </A></code> 
  212. and containing  <code><A href="_smal_BL#83"> #tib </A></code> @ bytes, but the 
  213. normal file operations should be used to access that keyboard line, rather than 
  214. using  <code><A href="_smal_BM#2f4"> tib </A></code> and  <code><A href="_smal_BL#83"> #tib </A></code> 
  215. .  
  216. <p>
  217. <p>
  218. <h2>division, floored</h2>
  219. <p>
  220. Integer division in which the remainder carries the sign of the divisor or is 
  221. zero, and the quotient is rounded to its arithmetic floor.  Note that, except 
  222. for error conditions, n1 n2  <code><A href="_smal_AW#2e6"> swap </A></code>  <code><A href="_smal_BH#28f"> over </A></code>  <code><A href="_smal_AD#f3"> /mod </A></code>  <code><A href="_smal_BA#2b8"> rot </A></code> 
  223. * + is identical to n1.  
  224. <p>
  225. <br><code>         Examples:</code><br>
  226. <br><code>             dividend  divisor      remainder  quotient</code><br>
  227. <br><code>                 10      7               3       1</code><br>
  228. <br><code>                -10      7               4      -2</code><br>
  229. <br><code>                 10     -7              -4      -2</code><br>
  230. <br><code>                -10     -7              -3       1</code><br>
  231. <p>
  232. <p>
  233. <h2>Return Stack</h2>
  234. <p>
  235. A last in, first out list which contains the addresses of word definitions whose 
  236. execution has not been completed by the address interpreter.  As a word 
  237. definition passes control to another definition, the return point is placed on 
  238. the return stack.  
  239. <p>
  240. The return stack may cautiously be used for other values, with the following 
  241. restrictions: 
  242. <p>
  243. <br><code>         a) The return stack may not be accessed inside a do-loop for</code><br>
  244. <br><code>            values placed on the return stack before the loop was entered.</code><br>
  245. <br><code>         b) Neither I nor J may be used to obtain the index of a loop if</code><br>
  246. <br><code>            values are placed and remain on the return stack within the</code><br>
  247. <br><code>            loop.</code><br>
  248. <br><code>         c) When the do-loop is executed all values placed on the return</code><br>
  249. <br><code>            stack within that loop must be removed before LOOP , +LOOP ,</code><br>
  250. <br><code>            or LEAVE is executed.</code><br>
  251. <br><code>         d) All values placed on the return stack within a colon definition</code><br>
  252. <br><code>            must be removed before the colon definition is terminated at ;</code><br>
  253. <br><code>            or before EXIT is executed.</code><br>
  254. <p>
  255. <br><code>         Examples of INCORRECT return stack usage:</code><br>
  256. <p>
  257. <br><code>         : FOO  >R  1 0  DO  R> .  LOOP  ;       \ violates restriction (a)</code><br>
  258. <br><code>         : FOO  1 0  DO  >R I . R>  LOOP ;       \ violates restriction (b)</code><br>
  259. <br><code>         : FOO  1 0  DO  I .  >R  LOOP  R> ;     \ violates restriction (c)</code><br>
  260. <br><code>         : FOO  >R  ;                            \ violates restriction (d)</code><br>
  261. <p>
  262. </body>
  263. </html>
  264.