SDSU CS 683 Emerging Technologies: Embracing Change
Spring Semester, 2001
Crash Recovery, Block Returns
Previous    Lecture Notes Index    Next    
© 2001, All Rights Reserved, SDSU & Roger Whitney
San Diego State University -- This page last updated 22-Feb-01

Contents of Doc 9, Crash Recovery, Block Returns


References

Squeak Source Code


Doc 9, Crash Recovery, Block Returns Slide # 2

Crash Recovery


At some point you are going to:


Don't panic!
Squeak saves all chances automatically for you

Once can recover changes

An ounce of prevention is worth a pound of Cure

When working on any sizable project frequently


This will


Doc 9, Crash Recovery, Block Returns Slide # 3

Crash Recovery - Same Image, GUI Tools


If your image has crashed, it is likely that one of the last things you did caused the crash. The following instructions tell you how to replay unsaved changes. If you replay all the changes, you are likely to crash the image. So select the changes you replay carefully.

Start the image. In the world menu select the "changes..." item. You get a menu like:



Select the item "recently logged changes". You get a menu asking you to select how far back you wish to go, like:




Doc 9, Crash Recovery, Block Returns Slide # 4
Once you selected how far back to browse you get a change list window:



The top pane lists changes and "do its" with the oldest on the top. Selecting items and using the menu in the top pane you can choose and file in the changes you want in the current image. The menu in the top pane is:



Here is your second warning. If your image has crashed, it is likely that one of the last things you did caused the crash. If you replay all the changes, you are likely to crash the image again. So select the changes you replay carefully.


Doc 9, Crash Recovery, Block Returns Slide # 5

Crash Recovery - Same Image, Text Tools


If you execute the following line:

ChangeList browseRecentLog

You will be asked how far back you wish to browse. You can proceed as described in the previous two slides.

If you execute the following line:

ChangeList browseRecent: 2000.

You will get a change list window on the last 2000 characters of change. You can then proceed as in the previous slide.

Crash Recovery - Different Image, Text Tools


If you execute the following line:

ChangeList browseFile: 'ChangesOfChangeSetOrStFileName'

You will get a change list window on the entire contents of the file listed. If you do this to a .change file you will have to wait a while for the operation to finish. Control-. (control key and the period) is the key command to interrupt Squeak.

How to Remember these Commands

Don't!

Computers are better at remembering such details. In the world menu select "help..." item to get the help menu. In the help menu select the "useful expressions" item. You will get a window full of useful expressions.


Doc 9, Crash Recovery, Block Returns Slide # 6

Blocks, Returns and Contexts


The Rules
A block with a return exists the method that created the block

Non local variables accessed in a block refer to the variables in the contexts the block was created not the context it is evaluated

The following examples illustrate these rules

Most of the time you do not have to worry about these rules, but you should know them


Doc 9, Crash Recovery, Block Returns Slide # 7
Example
Object subclass: #BlockTest
   instanceVariableNames: ''
   classVariableNames: ''
   poolDictionaries: ''
   category: 'Whitney-Examples'
Instance Methods
a: aBlock
   | x |
   x := 'b'.
   self log: 'Start a'.
   self b: aBlock.
   self log: 'End a'. 
   
b: aBlock
   | x |
   x := 'b'.
   self log: 'Start b'.
   aBlock value.
   self log: 'End b'. 
   
log: aString
   Transcript
      show: aString;
      cr.
   
startBlock
   self log: 'Start startBlock'.
   self a: [^5].
   self log: 'End startBlock'. 


Doc 9, Crash Recovery, Block Returns Slide # 8
Sample Program 1
|  test |
test := BlockTest new.
test a: [5 ].
Transcript
   show: 'The End'

Result in Transcript
Start a
Start b
End b
End a
The End

Sample Program 2

|  test |
test := BlockTest new.
test a: [^5].
Transcript
   show: 'The End'

Result in Transcript
Start a
Start b


Doc 9, Crash Recovery, Block Returns Slide # 9
Sample Program 3

|  test |
test := BlockTest new.
test startBlock.
Transcript
   show: 'The End'

Result in Transcript

Start startBlock
Start a
Start b
The End


Doc 9, Crash Recovery, Block Returns Slide # 10
Sample Program 4

| x test |
x := 'here'.
test := BlockTest new.
test a: [^x] 

Result Printed when Executed via "Print it"

'here'

Doc 9, Crash Recovery, Block Returns Slide # 11
Exercises

1. Create a new project. Create a new class, then exit the image without saving. Now restart the image and recover the changes. Stop reading this and go do it now. At some point you will crash your image before some deadline. At that point you will be tired and panicked. Not a good time to learn a new process.

2. The last expression in the "Useful expressions" window shows how to profile code in Squeak. Profile some code.

3. Browse all methods in Squeak whose names include the word "screen".

4. Try the block examples. Seeing is believing.


Copyright ©, All rights reserved.
2001 SDSU & Roger Whitney, 5500 Campanile Drive, San Diego, CA 92182-7700 USA.
OpenContent license defines the copyright on this document.

Previous    visitors since 22-Feb-01    Next