Squeak
  links to this page:    
View this PageEdit this PageUploads to this PageHistory of this PageTop of the SwikiRecent ChangesSearch the SwikiHelp Guide
Workspace shared variables
Last updated at 4:46 pm UTC on 8 September 2019
=== TO BE CHECKED BY AN EXPERIENCED SMALLTALKER ===========

According to the Blue Book Smalltalk has three kind of variables, Private, Shared and Temporary (see pg.21,51). There aren't in Smalltalk parlance global v.s. local variables.

A variable is Private when it is accessible only by one object, Shared when it is accessible by more objects and Temporary when it is defined into a | ... | block.

A programmer who types this into a Workspace
 myVar := 3.
 4 + myVar.  
 => 7        
may think he has defined a "global" variable. In some sense this is is true, this variable is accessible by all statements run in the same workspace.

Try to open another workspace and type
 myVar 
 => nil
Haha! The variable here is not defined. Se we can't really say it is "global". It could be most properly called "Workspace shared" variable.

Exercise. How do you get the list of all Workspace shared variables? Suggestion. You must send inspectBindings message to the Workspace object.

===========================================================================

Illustration

In the window below a variable called myVar is used.

Use_of_local_variables_in_a_workspace_2019-08-20.png

You may check that it is bound to the workspace if you bring up the HaloMorph (do central mouse click on the object of interest) and you choose the red icon -> 'debug menu' -> inspect morph.

Halos_for_a_Workspace_.png