1.4: Workspaces and Transcripts
- Page ID
\(\bigstar\) Close all open windows. Click on the
Tools tab at the far right of the Squeak environment to open the Tools flap.
You will see icons for some of the key tools in Squeak (Figure 1.3.3). Drag out a transcript and a workspace.
\(\bigstar\) Position and resize the transcript and workspace windows so that the workspace just overlaps the transcript.
You can resize windows either by dragging one of the corners, or by blue-clicking the window to bring up the morphic handles, and dragging the yellow, bottom right handle.
At any time only one window is active; it is in front and has its label highlighted. The mouse cursor must be in the window in which you wish to type.
The transcript is an object that is often used for logging system messages. It is a kind of “system console”. Note that the transcript is terribly slow, so if you keep it open and write to it certain operations can become 10 times slower. In addition the transcript is not thread-safe so you may experience strange problems if multiple objects write concurrently to the transcript.
Workspaces are useful for typing snippets of Smalltalk code that you would like to experiment with. You can also use workspaces simply for typing arbitrarily text that you would like to remember, such as to-do lists or instructions for anyone who will use your image. Workspaces are often used to hold documentation about a captured image, as is the case with the standard image that we downloaded earlier (see Figure 1.1.2).
\(\bigstar\) Type the following text into the workspace:
Transcript show: 'hello world'; cr.
Try double-clicking in the workspace at various points in the text you have just typed. Notice how an entire word, entire string, or the whole text is selected, depending on where you click.
\(\bigstar\) Select the text you have typed and yellow-click. Select
do it (d).
Notice how the text “hello world” appears in the transcript window (Figure 1.5.1). Do it again. (The
(d) in the menu item
do it (d) tells you that the keyboard shortcut to do it is CMD–d. More on this in the next section!)
You have just evaluated your first Smalltalk expression! You just sent the message
show: 'hello world' to the
Transcript object, followed by the message
cr (carriage return). The Transcript then decided what to do with this message, that is, it looked up its methods for handling
cr messages and reacted appropriately.
If you talk to Smalltalkers for a while, you will quickly notice that they generally do not use expressions like “call an operation” or “invoke a method”, but instead they will say “send a message”. This reflects the idea that objects are responsible for their own actions. You never tell an object what to do — instead you politely ask it to do something by sending it a message. The object, not you, selects the appropriate method for responding to your message.