Appendix A
Frequently Asked Questions

A.1 Getting started

FAQ 1 Where do I get the latest Pharo?

Answer  http://www.pharo-project.org/
FAQ 2 Which Pharo image should I use with this book?
Answer  You should be able to use any Pharo image, but we recommend you to use the prepared image on the Pharo by Example web site: http://PharoByExample.org. You should also be able to use most other images, but you may find that the hands-on exercises behave differently in surprising ways.

A.2 Collections

FAQ 3 How do I sort an OrderedCollection?

Answer  Send it the message asSortedCollection.
 
#(7 2 6 1) asSortedCollection -→ a SortedCollection(1 2 6 7)  

FAQ 4 How do I convert a collection of characters to a String?

Answer  
 
String streamContents: [:str | str nextPutAll: hello asSet] -→ hleo  

A.3 Browsing the system

FAQ 5 The browser does not look like the one described in the book. What gives?

Answer  You are probably using an image in which a different version of the OmniBrowser is installed as the default browser. In this book we assume that the OmniBrowser Package Browser is installed as the default. You can change the default by clicking on the menu bar of the browser. Just click on the gray lozenge in the top right corner of the window, select “Choose new default Browser”, and then pick the O2PackageBrowserAdaptor. The next browser you open will be the Package Browser.
PIC
(a) Choose a new browser
PIC
(b) Select the OB Package Browser

Figure A.1: Changing the default browser

FAQ 6 How do I search for a class?
Answer  CMD–b (browse) on the class name, or CMD–f in the category pane of the browser.
FAQ 7 How do I find/browse all sends to super?
Answer  The second solution is much faster:
 
SystemNavigation default browseMethodsWithSourceString: super. 
SystemNavigation default browseAllSelect: [:method | method sendsToSuper ].  

FAQ 8 How do I browse all super sends within a hierarchy?

Answer  
 
browseSuperSends := [:aClass | SystemNavigation default 
    browseMessageList: (aClass withAllSubclasses gather: [ :each | 
        (each methodDict associations 
            select: [ :assoc | assoc value sendsToSuper ]) 
                collect: [ :assoc | MethodReference class: each selector: assoc key ] ]) 
    name: Supersends of  , aClass name ,  and its subclasses]. 
browseSuperSends value: OrderedCollection.  

FAQ 9 How do I find out which new methods are introduced by a class? (I.e., not including overridden methods.)

Answer  Here we ask which methods are introduced by True:
 
newMethods := [:aClass| aClass methodDict keys select: 
    [:aMethod | (aClass superclass canUnderstand: aMethod) not ]]. 
newMethods value: True -→ an IdentitySet(#asBit #xor:)  

FAQ 10 How do I tell which methods of a class are abstract?

Answer  
 
abstractMethods := 
    [:aClass | aClass methodDict keys select: 
        [:aMethod | (aClass>>aMethod) isAbstract ]]. 
abstractMethods value: Collection -→ an IdentitySet(#remove:ifAbsent: #add: #do:)  

FAQ 11 How do I generate a view of the AST of an expression?

Answer  Load AST from squeaksource.com. Then evaluate:
 
(RBParser parseExpression: 3+4) explore  
(Alternatively explore it.)

FAQ 12 How do I find all the Traits in the system?

Answer  
 
Smalltalk allTraits  

FAQ 13 How do I find which classes use traits?

Answer  
 
Smalltalk allClasses select: [:each | each hasTraitComposition and: [each traitComposition notEmpty ]]  

A.4 Using Monticello and SqueakSource

FAQ 14 How do I load a SqueakSource project?

Answer  
1.
Find the project you want in http://squeaksource.com
2.
Copy the registration code snippet
3.
Select open Monticello browser
4.
Select +Repository HTTP
5.
Paste and accept the Registration code snippet; enter your password
6.
Select the new repository and Open it
7.
Select and load the latest version

FAQ 15 How do I create a SqueakSource project?

Answer  
1.
Go to http://squeaksource.com
2.
Register yourself as a new member
3.
Register a project (name = category)
4.
Copy the Registration code snippet
5.
open Monticello browser
6.
+Package to add the category
7.
Select the package
8.
+Repository HTTP
9.
Paste and accept the Registration code snippet; enter your password
10.
Save to save the first version

FAQ 16 How do I extend Number with Numberchf but have Monticello recognize it as being part of my Money project?

Answer  Put it in a method-category named *Money. Monticello gathers all methods that are in other categories named like *package and includes them in your package.

A.5 Tools

FAQ 17 How do I programmatically open the SUnit TestRunner?

Answer  Evaluate TestRunner open.
FAQ 18 Where can I find the Refactoring Browser?
Answer  Load AST then Refactoring Engine from squeaksource.com: http://www.squeaksource.com/AST http://www.squeaksource.com/RefactoringEngine
FAQ 19 How do I register the browser that I want to be the default?
Answer  Click the menu icon in the top right of the Browser window.

A.6 Regular expressions and parsing

FAQ 20 Where is the documentation for the RegEx package?

Answer  Look at the DOCUMENTATION protocol of RxParser class in the VB-Regex category.
FAQ 21 Are there tools for writing parsers?
Answer  Use SmaCC — the Smalltalk Compiler Compiler. You should install at least SmaCC-lr.13. Load it from http://www.squeaksource.com/SmaccDevelopment.html. There is a nice tutorial online: http://www.refactory.com/Software/SmaCC/Tutorial.html
FAQ 22 Which packages should I load from SqueakSource SmaccDevelopment to write parsers?
Answer  Load the latest version of SmaCCDev — the runtime is already there. (SmaCC-Development is for Squeak 3.8)