Advertisement
Guest User

Forth Naming Conventions

a guest
Aug 31st, 2021
183
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.88 KB | None | 0 0
  1.  
  2. Forth Naming Conventions ('Thinking FORTH')
  3. -------------------------------------------
  4.  
  5. Meaning Form Example
  6.  
  7. Arithmetic
  8. ----------
  9. integer 1 1name 1+
  10. integer 2 2name 2*
  11. takes relative input parameters +name +DRAW
  12. takes scaled input parameters *name *DRAW
  13.  
  14. Compilation
  15. -----------
  16. start of "high-level" code name: CASE:
  17. end of "high-level" code ;name ;CODE
  18. put something into dictionary name, C,
  19. executes at compile time [name] [COMPILE]
  20. slightly different name' (prime) CR'
  21. internal form or primitive (name) (TYPE)
  22. or <name> <TYPE>
  23. compiling word run-time part:
  24. systems with no folding lower-case if
  25. systems with folding (NAME) (IF)
  26. defining word :name :COLOR
  27. block-number where overlay begins namING DISKING
  28.  
  29. Data Structures
  30. ---------------
  31. table or array names EMPLOYEES
  32. total number of elements #name #EMPLOYEES
  33. current item number (variable) name# EMPLOYEE#
  34. sets current item ( n) name 13 EMPLOYEE
  35. advance to next element +name +EMPLOYEE
  36. size of offset to item from name+ DATE+
  37. beginning of structure
  38. size of (bytes per) /name /EMPLOYEE
  39. (short for BYTES/name)
  40. index pointer >name >IN
  41. convert address of structure to >name >BODY
  42. address of item
  43. file index (name) (PEOPLE)
  44. file pointer -name -JOB
  45. initialize structure 0name 0RECORD
  46.  
  47. Direction, Conversion
  48. ---------------------
  49. backwards name< SLIDE<
  50. forwards name> CMOVE>
  51. from <name <TAPE
  52. to >name >TAPE
  53. convert to name>name FEET>METERS
  54. downward \name \LINE
  55. upward /name /LINE
  56. open {name {FILE
  57. close }name }FILE
  58.  
  59. Logic, Control
  60. --------------
  61. return boolean value name? SHORT?
  62. returns reversed boolean -name? -SHORT?
  63. address of boolean 'name? 'SHORT?
  64. operates conditionally ?name ?DUP
  65. (maybe DUP)
  66. enable +name +CLOCK
  67. or, absence of symbol name BLINKING
  68. disable -name -CLOCK
  69. -BLINKING
  70. Memory
  71. ------
  72. save value of @name @CURSOR
  73. restore value of !name !CURSOR
  74. store into name! SECONDS!
  75. fetch from name@ INDEX@
  76. name of buffer :name :INSERT
  77. address of name 'name 'S
  78. address of pointer to name 'name 'TYPE
  79. exchange, especially bytes >name< >MOVE<
  80.  
  81. Numeric Types
  82. -------------
  83. byte length Cname C@
  84. 2 cell size, 2's complement Dname D+
  85. integer encoding
  86. mixed 16 and 32-bit operator Mname M*
  87. 3 cell size Tname T*
  88. 4 cell size Qname Q*
  89. unsigned encoding Uname U.
  90.  
  91. Output, Printing
  92. ----------------
  93. print item .name .S
  94. print numeric (name denotes type) name. D. , U.
  95. print right justified name.R U.R
  96.  
  97. Quantity
  98. --------
  99. "per" /name /SIDE
  100.  
  101. Sequencing
  102. ----------
  103. start <name <#
  104. end name> #>
  105.  
  106. Text
  107. ----
  108. string follows delimited by " name" ABORT" text"
  109. text or string operator "name "COMPARE
  110. (similar to $ prefix in BASIC)
  111. superstring array "name" "COLORS"
  112.  
  113.  
  114. Forth Naming Conventions ('Forth Programmer's Guide')
  115. -----------------------------------------------------
  116.  
  117. Where possible, a prefix before a name indicates the type or
  118. precision of the value being operated on, whereas a suffix
  119. after a name indicates what the value is or where it is stored.
  120.  
  121. Format Meaning Example
  122.  
  123. !name Store into name !DATA
  124.  
  125. #name Size or quantity #PIXELS
  126. Output numeric operator #S
  127. Buffer name #I
  128.  
  129. 'name Address of name 'S
  130. Address of pointer to name 'TYPE
  131.  
  132. (name) Internal component of name, not (IF)
  133. normally user-accessible (FIND)
  134. Run-time procedure of name (:)
  135. File index (PEOPLE)
  136.  
  137. *name Multiplication *DIGIT
  138. Takes scaled input parameter *DRAW
  139.  
  140. +name Addition +LOOP
  141. Advance +BUF
  142. Enable +CLOCK
  143. More powerful +INITIALIZE
  144. Takes relative input parameters +DRAW
  145.  
  146. -name Subtract, remove -TRAILING
  147. Disable -CLOCK
  148. not name (opposite of name) -DONE
  149. Returns reversed truth flag -MATCH
  150. (1 is false, 0 is true)
  151. Pointers, especially in files -JOB
  152.  
  153. .name Print named item .S
  154. Print from stack in named format .R .$
  155. Print following string ." string"
  156. May be further prefixed with data type D. U. U.R
  157.  
  158. /name Division /DIGIT
  159. Initialize routine or device /COUNTER
  160. "per" /SIDE
  161.  
  162. 1name First item of a group 1SWITCH
  163. Integer 1 1+
  164. One-byte size 1@
  165.  
  166. 2name Second item of a group 2SWITCH
  167. Integer 2 2/
  168. Two-cell size 2@
  169.  
  170. ;name End of something ;S
  171. End of something, start of something ;CODE
  172. else
  173.  
  174. <name Less than <LIMIT
  175. Open bracket <#
  176. From device name <TAPE
  177.  
  178. <name> Name of an internal part of a device <TYPE>
  179. driver routine
  180.  
  181. >name Towards name >R, >TAPE
  182. Index pointer >IN
  183. Exchange, especially bytes >< (swap bytes)
  184. >MOVE< (move,
  185. swapping bytes)
  186.  
  187. ?name Check condition, return true if yes ?TERMINAL
  188. Conditional operator ?DUP
  189. Check condition, abort if bad ?STACK
  190. Fetch contents of name and display ?N
  191.  
  192. @name Fetch from name @INDEX
  193.  
  194. Cname One-byte character size, integer C@
  195.  
  196. Dname Double-cell integer D+
  197.  
  198. Mname Mixed single and double operator M*
  199.  
  200. Tname Three-cell size T*
  201.  
  202. Uname Unsigned encoding U.
  203.  
  204. [name] Executes at compile time [']
  205.  
  206. \name Unsigned subtraction (ramp-down) \LOOP
  207.  
  208. name! Store into name B!
  209.  
  210. name" String follows, delimited by " ABORT" xxx"
  211.  
  212. name, Put something into dictionary C,
  213.  
  214. name: Start definition CASE:
  215.  
  216. name> Close bracket #>
  217. Away from name R>
  218.  
  219. name? Same as ?name B?
  220.  
  221. name@ Fetch from name B@
  222.  
  223.  
  224.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement