links to this page:    
View this PageEdit this PageUploads to this PageHistory of this PageTop of the SwikiRecent ChangesSearch the SwikiHelp Guide
On to Smalltalk - Modifications for using with Squeak
Last updated at 4:59 pm UTC on 27 November 2003
Patrick Henry Winston's On To Smalltalk uses Smalltalk express, which differs enough from Squeak to frighten away beginners. One squeaker wrote a list of differences to help a friend learn Smalltalk using Squeak. Corrections based on page number follow here. Please make corrections or improvements.

24 Entering squeak may be more difficult that clicking the appropriate icon. On Unix, try the command line ./SqueakVM-2.3-i386-linux-2.0.36 -memory 32m Squeak2.3.image

Left click on the desktop. Choose open. From the submenu choose transcript.

To open a workspace, move the mouse over the orange tools flap on the right edge. Drag a workspace from the flap onto the desktop. (The workspace is the yellow window, second from the top of the flap.)

25 To ShowIt, you click the middle mouse button, not the right one. The command is named PrintIt, not ShowIt.

If you prefer, fewer mouse clicks, you can take advantage of two shortcuts. First, if you don't bother to select anything, Squeak assumes you want to operate on the entire line containing the cursor. Second, you can type meta-p instead of clicking the middle mouse button and choosing PrintIt.

42 Meta-d is a shortcut for DoIt.

53 Click anywhere in the workspace, choose "Quit".

81 In Squeak, you use a System Browser, not a class hierarchy browser. From the tools flap, drag out the green window at the top of the flap.

82 This is not a hierarchy browser, so it does not reflect the subclass structure. Instead the classes are organized into categories, given descriptive names.

83 There are no ellipses. When you select a category in the leftmost pane, all the objects in that category are listed in the second pane.

85 To find the Integer class, you select the category Numeric-Numbers in the leftmost pane. When you select the Integer class, you don't see all of its methods, you instead see all of its method categories. When you select one of those categories, you then see the methods in that category.

86 To define a new method, you need not click Method->New Method, you just start typing in the bottom pane.

88 This browser has no variables window.

89 When you type the caret, it will appear as an up arrow.

97 Middle click, choose accept instead of right click, choose save.

99 Click on desktop, choose "Save and Quit".

198 See comment 81 :-)

199 This is a category browser, not a hierarchy browser. We must put our vegetable class in some category. We could use any existing category, but none of them seem appropriate for vegetables. So lets create a new category for them. Move the mouse into the System Browser's top left pane. (That's the pane with all the object categories). Middle click and choose "add item". Name the new category "Winston-Tutorial". (click accept, or type meta-s, or tap return). Now scroll through that pane, find the category you just added, and select it. The following will appear in the bottom window of the browser.

Object subclass: #NameOfClass
instanceVariableNames: 'instVarName1 instVarName2'
classVariableNames: 'ClassVarName1 ClassVarName2'
poolDictionaries: ''
category: 'Winston-Tutorial'

In the top line, select "NameOfClass" and type "Vegetable". The contents of the bottom window should now look like this:

Object subclass: #Vegetable
instanceVariableNames: 'instVarName1 instVarName2'
classVariableNames: 'ClassVarName1 ClassVarName2'
poolDictionaries: ''
category: 'Winston-Tutorial'

200 Ignore

202 In the second line, select "instVarName1 instVarName2" and type "fCalories cCalories pCalories". In the third line, select "ClassVarName1 ClassVarName1" and tap Backspace.

206 Use middle->accept, not right->save.

207 The name Vegetable appears in the second pane along the top. There is no variables window in this browser.

213 To enter a method definition, you must select a method category from the third pane along the top. At present there is only one category: "no methods". Select that, then type your method definition into the bottom pane.

299 This contains a typo; the last block should be [n := n - 1], not [n = n - 1].

358 You may use assignment to create and initialize globals in Squeak.

445 It is indeed implementation dependent. Squeak's file handling objects live in the category System-Files.

447 Squeak has no File class. To create a FileStream in Squeak, use "FileStream fileNamed: 'vtbls.dta'".

450 Squeak strings have no asInteger method. They do have an asNumber method, which does what you would expect.

464 Squeak includes a nextNumber method.

466 Squeak includes the readFrom: method.

486 Squeak has formatting features built in to do all the tasks described in this section. A string may be padded with padded:to:with:, may be truncated with or without ellipsis, or formatted many other ways, browse the methods of class String to learn what they are. But you should still read this section, as practice reading Smalltalk. For extra credit, try comparing the methods Patrick Henry Winston presents with the equivalent methods in the image.

525 Ignore View Managers – Squeak does this differently.

527 Squeak includes the Random object, which provides random numbers.

558 In Squeak, this should be handled using the adaptor methods adaptToNumber:andSend: and adaptToWeight:andSend:. You can see examples of these adapter methods in the converting method category of Number, Integer, Fraction, and Float.

559 This should not be done; Squeak has already defined these methods for Weight in its superclass, Magnitude.

567 Middle click -> debug, or click the small red 'd' in the title bar.

573 Hop corresponds to middle click -> send.

574 Skip corresponds to middle click -> step, and Jump to middle click -> proceed.

577 In Squeak, breakpoints must be added to the source code. Just type "self halt." where you want the break.

581 Middle click -> senders, Middle click -> implementors.

582 Middle click -> inspect.

583 Middle->PrintIt, not right->ShowIt. But you remembered that, right?

591 Squeak uses subclassResponsibility instead of implementedBySubclass.

601 Middle->FileOut. You won't get to choose a class name; it is chosen for you automatically.

603 Globals can be filed out in Squeak, but I'm too lazy to explain.

604 From the tools flap, drag in a file list window. That's the pink one, third from the top. Select your file in the top right pane, middle->fileIn. No need to select the entire contents of the file in the lower pane.

605 Remember, in Squeak you use FileStream fileNamed: in place of File pathName:.

613 To do this, you may want to convert the line endings to your platform native format, then back to Squeak's format when done.

628 Rectangle already has an area function.

631 Stop here, do not go on. Subsequent chapters differ too much from the Squeak way.