home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Interactive Guide / c-cplusplus-interactive-guide.iso / c_ref / csource4 / 232_01 / userman < prev    next >
Text File  |  1987-06-17  |  22KB  |  861 lines

  1. .ds CM
  2. .TL
  3. A Little Smalltalk
  4. User Manual
  5. .AU
  6. Timothy A. Budd
  7. .po +0.2i
  8. .nr PO +0.2i
  9. .NH 1
  10. Introduction
  11. .PP
  12. This manual is intended as an aid in using the Little Smalltalk system.
  13. It is not intended to be used as an introduction to the Smalltalk
  14. language.
  15. Little Smalltalk is largely (with exceptions listed in a later section)
  16. a subset of the Smalltalk-80\s-2\u*\d\s+2 language described
  17. .FS
  18. * Smalltalk-80 is a trademark of the Xerox Corporation.
  19. .FE
  20. in [.Smalltalk blue.].
  21. A complete description of the classes included in the Little Smalltalk system
  22. and the messages they accept is given in Appendix 1.
  23. .NH 1
  24. Running the system
  25. .PP
  26. The Little Smalltalk system is invoked by typing the command \fBst\fP.
  27. The system is interactive \- that is, the user types an expression at the
  28. keyboard and the system responds by evaluating the expression and typing
  29. the result.
  30. For example,
  31. typing the expression \fB3 + 4\fP results in the value \fB7\fP being
  32. displayed on
  33. the output.  Execution is terminated by typing control\-D.  A sample
  34. execution session is shown in Figure 1.
  35. .KF
  36. .sp
  37. .DS B
  38. % st
  39. Little Smalltalk
  40.     3 + 4
  41. 7
  42.     ^D
  43. %
  44. .DE
  45. .sp
  46. .ce
  47. \fBFigure 1:\fP A Sample Little Smalltalk Session
  48. .sp
  49. .KE
  50. .PP
  51. Instance variables for the command level can be created by
  52. assigning a value to a new variable name.  Thereafter that variable can
  53. be used at the command level, although it is not known within the scope
  54. of any method.  The variable ``last'' always contains the value
  55. returned by the last expression typed.
  56. Figure 2 shows the creation of a variable.
  57. Note that the assignment arrow is formed as a two character sequence.
  58. .KF
  59. .sp
  60. .DS B
  61. .ta 5m
  62.     newvar <\(mi 2 / 3
  63.     newvar
  64. 0.666667
  65.     2 raisedTo: newvar + (4 / 3)
  66. 4
  67.     last
  68. 4
  69. .DE
  70. .sp
  71. .ce
  72. \fBFigure 2:\fP Creating Variables
  73. .sp
  74. .KE
  75. .PP
  76. The default behavior is for the value of expressions,
  77. with the exception of assignments, to be typed
  78. automatically as they are evaluated.
  79. This behavior can be modified either by using the \-d flag
  80. (see Appendix 2), or by passing a message to the pseudo
  81. variable \fBsmalltalk\fP (see Appendix 1).
  82. .PP
  83. Class descriptions must be read in from files, they cannot be entered
  84. interactively.  Class descriptions are entered using a system directive.
  85. For example, to include a class description contained in a file named
  86. \fBnewclass.st\fP, the following system directive should be issued:
  87. .sp
  88. .ce
  89. )i newclass.st
  90. .sp
  91. A list of files containing class descriptions can also be given as
  92. arguments to the st command.  The command
  93. .DS B
  94. %st file\s-2\d1\u\s+2 ... file\s-2\dn\u\s+2
  95. .DE
  96. is equivalent to the sequence
  97. .DS B
  98. .ta 5m
  99. %st
  100. Little Smalltalk
  101.     )i file\s-2\d1\u\s+2
  102.     ...
  103.     )i file\s-2\dn\u\s+2
  104. .DE
  105. .PP
  106. A table of system directives is given in Figure 3.
  107. .KF
  108. .sp
  109. .TS
  110. center box;
  111. l lw(4.5i).
  112.  
  113. )e filename    T{
  114. Edit the named file.  The Little Smalltalk system will suspend, leaving
  115. the user in an editor for making changes to the named file.  Upon leaving
  116. the editor the named file will automatically be included, as if the )i
  117. directive had been typed.
  118. T}
  119.  
  120. )g filename    T{
  121. Search for an entry in the system library area matching the filename.
  122. If found, the class descriptions in the library entry are included.
  123. This command is useful for including commonly used classes that are not
  124. part of the standard prelude, such as classes for statistics applications
  125. or graphics.
  126. T}
  127.  
  128. )i filename    T{
  129. Include the named file.  The file must contain one or more class descriptions.
  130. The class descriptions are parsed, and if syntactically legal new
  131. instances of class \fBClass\fP are added to the Smalltalk system.
  132. T}
  133.  
  134. )l filename    T{
  135. Load a previously saved environment from the named file.
  136. The current values of all variables are overridden.
  137. The file must have been created using the )s directive (below).
  138. T}
  139.  
  140. )r filename    T{
  141. Read the named file.  The file must contain Smalltalk statements, as
  142. would be typed at the keyboard.  The effect is just as if the lines
  143. of the file had been typed at the keyboard.  The file cannot contain
  144. class descriptions.
  145. T}
  146.  
  147. )s filename    T{
  148. Save the current state in the named file.  The values of all variables
  149. are saved, and can later be reloaded using the )l directive (above).
  150. T}
  151.  
  152. )!string    T{
  153. Execute the remainder of the line following the exclamation point
  154. as a Unix\s-2\u*\d\s+2 command.  Nothing is done with the output of the command,
  155. nor is the returning status of the command recorded.
  156. T}
  157.  
  158. .TE
  159. .sp
  160. .ce
  161. \fBFigure 3:\fP System Directives
  162. .sp
  163. .KE
  164. .PP
  165. Note that the )e system directive invokes an editor on a file
  166. containing class descriptions, and then automatically includes the file
  167. when the editor is exited.
  168. Classes also respond to the message \fBedit\fP, which will have the same
  169. effect as the )e directive applied to the file containing the class
  170. description.
  171. Thus the typical debug/edit/debug cycle
  172. involves repeated uses of the )e directive or the \fBedit\fP message
  173. until a desired outcome is achieved.
  174. The editor invoked by the )e directive can be changed by setting
  175. the EDITOR variable in the users environment.
  176. .NH 1
  177. Differences between Little Smalltalk and the Smalltalk-80 system
  178. .PP
  179. This section describes the differences between the language accepted by
  180. the Little Smalltalk system and the language described in
  181. [.Smalltalk blue.].  The principal reasons for these changes are
  182. as follows:
  183. .IP size 6.5m
  184. Classes which are largely unnecessary, or which could be easily
  185. simulated by other classes (e.g. Association, SortedCollection) have
  186. been eliminated in the interest of keeping the size of the standard
  187. library as small as possible.  Similarly, indexed instance variables are
  188. not supported, since to do so would increase the size of every object in
  189. the system, and they can be easily simulated in those classes in which
  190. they are important (see below).
  191. .IP portability
  192. Classes which depend upon particular hardware (e.g. BitBlt) are not included
  193. as part of the Little Smalltalk system.  The basic system assumes nothing
  194. more than ascii terminals.
  195. .IP representation
  196. The need for a textual representation for class descriptions required some
  197. small additions to the syntax for class methods (see Appendix 3).
  198. Similarly, the fact that classes and subclasses can be separately parsed,
  199. in either order, forced some changes in the scoping rules for instance
  200. variables.
  201. .PP
  202. The following sections describe these changes in more detail.
  203. .NH 2
  204. No Browser
  205. .PP
  206. The Smalltalk-80 Programming Environment described in [.Smalltalk orange.]
  207. is not included as part of the Little Smalltalk system.  The Little
  208. Smalltalk system is designed to be little, easily portable, and to
  209. rely on nothing more than basic terminal capabilities.
  210. .NH 2
  211. Internal Representation Different
  212. .PP
  213. The internal representations of objects, including processes, interpreters,
  214. and bytecodes, is entirely different in the Little Smalltalk system from
  215. the Smalltalk-80 system described in [.Smalltalk blue.].
  216. .FS
  217. * Unix is a trademark of Bell Laboratories.
  218. .FE
  219. .NH 2
  220. Fewer Classes
  221. .PP
  222. Many of the classes described in [.Smalltalk blue.] are not included as
  223. part of the Little Smalltalk basic system.  Some of these are not
  224. necessary because of the decision not to include the editor, browser,
  225. and so on as part of the basic system.  Others are omitted in the interest
  226. of keeping the standard library of classes small.  A complete list
  227. of included classes for the Little Smalltalk system is given in Appendix 1.
  228. .NH 2
  229. No Class Protocol
  230. .PP
  231. Protocol for all classes is defined as part of class \fBClass\fP.
  232. It is not possible to redefine class protocol as part of a class description,
  233. only instance protocol.
  234. The notion of metaclasses is not supported.
  235. .NH 2
  236. Cascades Different
  237. .PP
  238. The semantics of cascades has been simplified and generalized.
  239. The result of a cascaded expression is always the result of the expression
  240. to the left of the first semicolon, which is also the receiver for each
  241. subsequent continuation.  Continuations can include multiple messages.
  242. A rather nonsensical, but illustrative,