Workspace

 


 

A Workspace is a general text pane where snippets of Smalltalk code can be edited and executed (in Smalltalk parlance, evaluated). A Workspace allows you to interactively communicate with any of the objects in your image and this is one of the features that make programming in Smalltalk such a productive experience.

To execute a piece of Smalltalk code you use the Workspace/Evaluate it command. If the code occupies a single line, simply place the cursor on the line and choose Evaluate it. If it spans several lines you must first select the appropriate text before evaluating it. Evaluating a piece of Smalltalk will always cause something to happen but will not display any result that might be returned from this effort. In order to evaluate some code and display the answer, you should use Workspace/Display it.

Tip: Ctrl+E and Ctrl+D are useful shortcuts for Evaluate it and Display it respectively.

The contents of a Workspace can be associated with a file. Simply choose File/Save or use the Save button on the toolbar. This can be useful if you wish to set up a file containing a script of actions that can be replayed at a later date.

Tip: You can also use a Workspace as a general-purpose text file editor.

Workspace local variables

Sometimes, when working in a Workspace, it is useful to be able to save the results of intermediate evaluations. If you assign them to an, as yet, undefined variable with a lowercase name, then a new variable slot with this name will automatically be created and attached to the workspace. You can use this variable in subsequent expressions and it will remain in existence until the Workspace is closed.

Tip: If you assign the result of an expression to an undefined variable name beginning with an uppercase letter then you will be prompted and asked if you wish to create a new global variable (in the Smalltalk dictionary). In general, it is not a good idea to create new globals in this way. It is better to make use of Workspace local variables since they are cleaned up automatically when the Workspace is closed.

Workspace pools

Smalltalk makes use of pool constants dictionaries to associate symbolic names with values. For example, if you are manipulating windows at a low level you might want to make use of the constant SW_SHOW (5) from "windows.h". In Dolphin, the constants from " windows.h" are held in a PoolConstantsDictionary called Win32Constants. Should you want to make use of these symbolic constants when evaluating expressions in a Workspace then you must first associate the appropriate pool dictionary with the Workspace. To do this you can use the Workspace/Pools command and you will be prompted to select one or more of the existing PoolConstantsDictionaries to attach to the Workspace.

Cloning a Workspace

You can create an exact copy of any Workspace, including its text contents, local variables and pools, using the Clone workspace command from the Workspace context menu. The clone will be opened into a new window.