www.delorie.com/gnu/docs/smalltalk/gst_12.html   search  
 
Buy GNU books!


GNU Smalltalk User's Guide

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

2.2.3 Syntax

Global objects of an environment (local or inherited) may be referenced by their symbol used in the source code, e.g.
 
            John goHome

if the #John -> aMan association exists in the particular environment or one of its super-environments, all along the way to the root environment.

If an object has to be referenced from another environment (i.e. which is not on the inheritance link) it has to be referenced either relatively to the position of the current environment (using the Super symbol), or absolutely (using the "full pathname" of the object, navigating from Smalltalk through the tree of sub-environments).

For the identification of global objects in another environment a "pathname" of symbols is used. The symbols are separated by blanks, i.e. the "look" to be implemented is that of
 
Smalltalk Tasks MyTask

and of
 
Super Super Peter.

Its similarity to a sequence of message sends is not casual, and suggests the following syntax for write access:(4)
 
Smalltalk Tasks MyTask: anotherTask

This resembles the way accessors are used for other objects. As it is custom in Smalltalk, however, we are reminded by uppercase letters that we are accessing global objects.

In addition, a special syntax has been implemented that returns the Association object for a particular global: so the last example above can be written also like
 
#{Smalltalk.Tasks.MyTask} value: anotherTask

This special kind of literal (called a variable binding) is also valid inside literal arrays.


  webmaster     delorie software   privacy  
  Copyright 2003   by The Free Software Foundation     Updated Jun 2003