CPS 343/543 Lecture notes: Introduction to Squeak

Coverage: [QTOL]

Working with squeak

  • demo of environment
  • local image of everything in your own directory

Basic interaction

  • Workspace window
  • Transcript window
  • System browser

Communicating between windows

  • Transcript show: 'hello'
  • Transcript show: cr
  • 2+3 arithmetic expressions really involve objects communicating through messages
  • browsing through existing classes in the System Browser

Other things to know about Squeak

  • saving and loading classes
  • a convenient way to access all of your code, from which you can copy and paste it to a file, from which you can print it
  • to dump your code to an HTML file, click printOut

Fun stuff

  • morph is the root of all graphical objects in Smalltalk
  • destroying the Energizer bunny - bunny destroy

A sample workspace

    Transcript open.
    Transcript show: 'hello'
    3 + 4 7
    1 to: 5 do: [:i | (Transcript show: 'Hello World') cr]
    prompt _ FillInTheBlank request: 'How may I help you, Linus?'
    N _ 6
    N class.
    <class name> selectors
    <class name> superclass.
    <class name> allSubclasses.
    <class name> withAllSubclasses.
    <class name> withAllSuperclasses.
    N decrement 6
    N _ Dictionary new.
    N inspect. "reflection"
    N at: '4:30' put: 'cps343'
    N at: '5:55' put: 'cps445'
    N _ 90.
    N inspect. 
    Object withAllSubclasses do: 
        [:clas | clas selectors do:
             [:sel | 
    	         (sel asLowercase includesSubString: 'random')
    	          ifTrue: [
    		            Transcript show: clas name.
    		            Transcript show: ' '.
    		            Transcript show: sel.
    		            Transcript cr]]].
    Morph new openInWorld.


    [QTOL] G. Korienek, T. Wrensch, D. Dechow. Squeak: A Quick Trip To ObjectLand.. Addison-Wesley, Boston, MA, 2002.

Return Home